diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-19 11:48:09 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-09 02:39:05 -0400 |
commit | 2ec3a12a667847d303d4d0c0576d5ff388052b48 (patch) | |
tree | a4f4aa400653a513f986622def425f6bba0ccc99 | |
parent | 594822918de20bf3a50afbc4de65b6f2971a92db (diff) |
cachefiles_write_page(): switch to __kernel_write()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/cachefiles/rdwr.c | 48 | ||||
-rw-r--r-- | fs/read_write.c | 2 |
2 files changed, 21 insertions, 29 deletions
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index 25e745b8eb1b..616db0e77b44 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c | |||
@@ -880,7 +880,6 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) | |||
880 | { | 880 | { |
881 | struct cachefiles_object *object; | 881 | struct cachefiles_object *object; |
882 | struct cachefiles_cache *cache; | 882 | struct cachefiles_cache *cache; |
883 | mm_segment_t old_fs; | ||
884 | struct file *file; | 883 | struct file *file; |
885 | struct path path; | 884 | struct path path; |
886 | loff_t pos, eof; | 885 | loff_t pos, eof; |
@@ -914,36 +913,27 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) | |||
914 | if (IS_ERR(file)) { | 913 | if (IS_ERR(file)) { |
915 | ret = PTR_ERR(file); | 914 | ret = PTR_ERR(file); |
916 | } else { | 915 | } else { |
917 | ret = -EIO; | 916 | pos = (loff_t) page->index << PAGE_SHIFT; |
918 | if (file->f_op->write) { | 917 | |
919 | pos = (loff_t) page->index << PAGE_SHIFT; | 918 | /* we mustn't write more data than we have, so we have |
920 | 919 | * to beware of a partial page at EOF */ | |
921 | /* we mustn't write more data than we have, so we have | 920 | eof = object->fscache.store_limit_l; |
922 | * to beware of a partial page at EOF */ | 921 | len = PAGE_SIZE; |
923 | eof = object->fscache.store_limit_l; | 922 | if (eof & ~PAGE_MASK) { |
924 | len = PAGE_SIZE; | 923 | ASSERTCMP(pos, <, eof); |
925 | if (eof & ~PAGE_MASK) { | 924 | if (eof - pos < PAGE_SIZE) { |
926 | ASSERTCMP(pos, <, eof); | 925 | _debug("cut short %llx to %llx", |
927 | if (eof - pos < PAGE_SIZE) { | 926 | pos, eof); |
928 | _debug("cut short %llx to %llx", | 927 | len = eof - pos; |
929 | pos, eof); | 928 | ASSERTCMP(pos + len, ==, eof); |
930 | len = eof - pos; | ||
931 | ASSERTCMP(pos + len, ==, eof); | ||
932 | } | ||
933 | } | 929 | } |
934 | |||
935 | data = kmap(page); | ||
936 | file_start_write(file); | ||
937 | old_fs = get_fs(); | ||
938 | set_fs(KERNEL_DS); | ||
939 | ret = file->f_op->write( | ||
940 | file, (const void __user *) data, len, &pos); | ||
941 | set_fs(old_fs); | ||
942 | kunmap(page); | ||
943 | file_end_write(file); | ||
944 | if (ret != len) | ||
945 | ret = -EIO; | ||
946 | } | 930 | } |
931 | |||
932 | data = kmap(page); | ||
933 | ret = __kernel_write(file, data, len, &pos); | ||
934 | kunmap(page); | ||
935 | if (ret != len) | ||
936 | ret = -EIO; | ||
947 | fput(file); | 937 | fput(file); |
948 | } | 938 | } |
949 | 939 | ||
diff --git a/fs/read_write.c b/fs/read_write.c index 009d8542a889..7d9318c3d43c 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -513,6 +513,8 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t | |||
513 | return ret; | 513 | return ret; |
514 | } | 514 | } |
515 | 515 | ||
516 | EXPORT_SYMBOL(__kernel_write); | ||
517 | |||
516 | ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) | 518 | ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) |
517 | { | 519 | { |
518 | ssize_t ret; | 520 | ssize_t ret; |