]> git.karo-electronics.de Git - linux-beck.git/commitdiff
simple_write_end(): don't zero in short copy into uptodate
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 30 Aug 2016 02:39:56 +0000 (22:39 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 10 Dec 2016 19:25:19 +0000 (14:25 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/libfs.c

index 48826d4da189ec0373f24c16a89e4f1066815200..76048705d9220d3234f36ad151dd93d81ef839f6 100644 (file)
@@ -465,6 +465,8 @@ EXPORT_SYMBOL(simple_write_begin);
  * is not called, so a filesystem that actually does store data in .write_inode
  * should extend on what's done here with a call to mark_inode_dirty() in the
  * case that i_size has changed.
+ *
+ * Use *ONLY* with simple_readpage()
  */
 int simple_write_end(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned copied,
@@ -474,14 +476,14 @@ int simple_write_end(struct file *file, struct address_space *mapping,
        loff_t last_pos = pos + copied;
 
        /* zero the stale part of the page if we did a short copy */
-       if (copied < len) {
-               unsigned from = pos & (PAGE_SIZE - 1);
-
-               zero_user(page, from + copied, len - copied);
-       }
+       if (!PageUptodate(page)) {
+               if (copied < len) {
+                       unsigned from = pos & (PAGE_SIZE - 1);
 
-       if (!PageUptodate(page))
+                       zero_user(page, from + copied, len - copied);
+               }
                SetPageUptodate(page);
+       }
        /*
         * No need to use i_size_read() here, the i_size
         * cannot change under us because we hold the i_mutex.