Commit 2ec3a12a authored by Al Viro's avatar Al Viro

cachefiles_write_page(): switch to __kernel_write()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 59482291
...@@ -880,7 +880,6 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) ...@@ -880,7 +880,6 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
{ {
struct cachefiles_object *object; struct cachefiles_object *object;
struct cachefiles_cache *cache; struct cachefiles_cache *cache;
mm_segment_t old_fs;
struct file *file; struct file *file;
struct path path; struct path path;
loff_t pos, eof; loff_t pos, eof;
...@@ -914,36 +913,27 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) ...@@ -914,36 +913,27 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
if (IS_ERR(file)) { if (IS_ERR(file)) {
ret = PTR_ERR(file); ret = PTR_ERR(file);
} else { } else {
ret = -EIO; pos = (loff_t) page->index << PAGE_SHIFT;
if (file->f_op->write) {
pos = (loff_t) page->index << PAGE_SHIFT; /* we mustn't write more data than we have, so we have
* to beware of a partial page at EOF */
/* we mustn't write more data than we have, so we have eof = object->fscache.store_limit_l;
* to beware of a partial page at EOF */ len = PAGE_SIZE;
eof = object->fscache.store_limit_l; if (eof & ~PAGE_MASK) {
len = PAGE_SIZE; ASSERTCMP(pos, <, eof);
if (eof & ~PAGE_MASK) { if (eof - pos < PAGE_SIZE) {
ASSERTCMP(pos, <, eof); _debug("cut short %llx to %llx",
if (eof - pos < PAGE_SIZE) { pos, eof);
_debug("cut short %llx to %llx", len = eof - pos;
pos, eof); ASSERTCMP(pos + len, ==, eof);
len = eof - pos;
ASSERTCMP(pos + len, ==, eof);
}
} }
data = kmap(page);
file_start_write(file);
old_fs = get_fs();
set_fs(KERNEL_DS);
ret = file->f_op->write(
file, (const void __user *) data, len, &pos);
set_fs(old_fs);
kunmap(page);
file_end_write(file);
if (ret != len)
ret = -EIO;
} }
data = kmap(page);
ret = __kernel_write(file, data, len, &pos);
kunmap(page);
if (ret != len)
ret = -EIO;
fput(file); fput(file);
} }
......
...@@ -513,6 +513,8 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t ...@@ -513,6 +513,8 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
return ret; return ret;
} }
EXPORT_SYMBOL(__kernel_write);
ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
{ {
ssize_t ret; ssize_t ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment