Whamcloud - gitweb
LU-3044 llite: LSeek SEEK_CUR incorrect after O_APPEND write
authorPatrick Farrell <paf@cray.com>
Fri, 29 Mar 2013 17:41:34 +0000 (12:41 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 23 Apr 2013 05:18:55 +0000 (01:18 -0400)
When a file is opened with O_APPEND set and a write is done,
the file offset value immediately after the write is incorrect.
It is too much by approximately the length of the write.

This can be seen by doing lseek SEEK_CUR immediately after the
write. This does not cause corruption on subsequent writes
because with O_APPEND VFS resets the file offset to EOF before
each write.

This is resolved by removing the change made for BUG:17711,
which was to set crw_pos in ll_prepare_write.

That change was to pass the LASSERT(cl_page_in_io(page, io)) in
cl_io_prepare_write().  However, this assert has since been
modified to exclude the O_APPEND case, making this unnecessary.

crw_pos is also updated in cl_io_rw_advance which is why pos is
greater than expected.

Removing the extra update to crw_pos in ll_prepare_write fixes
this.

Signed-off-by: Patrick Farrell <paf@cray.com>
Change-Id: I7c1ad10eefec44aae415b8cfce6b01bc9b39fc8f
Reviewed-on: http://review.whamcloud.com/5861
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/llite/rw.c

index f8eb719..0cf7ab2 100644 (file)
@@ -237,18 +237,8 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from,
                 struct cl_page *page = lcc->lcc_page;
 
                 cl_page_assume(env, io, page);
-                if (cl_io_is_append(io)) {
-                        struct cl_object   *obj   = io->ci_obj;
-                        struct inode       *inode = ccc_object_inode(obj);
-                        /**
-                         * In VFS file->page write loop, for appending, the
-                         * write offset might be reset according to the new
-                         * file size before holding i_mutex. So crw_pos should
-                         * be reset here. BUG:17711.
-                         */
-                        io->u.ci_wr.wr.crw_pos = i_size_read(inode);
-                }
-                result = cl_io_prepare_write(env, io, page, from, to);
+                
+               result = cl_io_prepare_write(env, io, page, from, to);
                 if (result == 0) {
                         /*
                          * Add a reference, so that page is not evicted from