From 48fcf440fe5f9728e3dcdf411bd7969b01e4449d Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 29 Mar 2013 12:41:34 -0500 Subject: [PATCH 1/1] LU-3044 llite: LSeek SEEK_CUR incorrect after O_APPEND write 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 Change-Id: I7c1ad10eefec44aae415b8cfce6b01bc9b39fc8f Reviewed-on: http://review.whamcloud.com/5861 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger --- lustre/llite/rw.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index f8eb719..0cf7ab2 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -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 -- 1.8.3.1