From: Jinshan Xiong Date: Thu, 15 Sep 2011 05:49:21 +0000 (-0700) Subject: LU-683: handle short write in cl_io_commit_write X-Git-Tag: 2.1.0~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=ff38d3f6ba13e8c251a2fdc070bae3cb2098a4a4;ds=sidebyside LU-683: handle short write in cl_io_commit_write CLIO has to handle short write case where no bytes were actually copied from user space. In this case, we should avoid adding that page into cache. Change-Id: I78c870e741d7bdb2a9c4c0bfba1adc50a6e814e7 Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/1383 Tested-by: Hudson Tested-by: Yu Jian Reviewed-by: Oleg Drokin Reviewed-by: Bobi Jam --- diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 25f45fb..d5e012e 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -294,7 +294,7 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, struct lu_env *env; struct cl_io *io; struct cl_page *page; - int result; + int result = 0; ENTRY; lcc = ll_cl_get(); @@ -303,11 +303,14 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, io = lcc->lcc_io; LASSERT(cl_page_is_owned(page, io)); - result = cl_io_commit_write(env, io, page, from, to); + LASSERT(from <= to); + if (from != to) /* handle short write case. */ + result = cl_io_commit_write(env, io, page, from, to); if (cl_page_is_owned(page, io)) cl_page_unassume(env, io, page); + /* - * Release reference acquired by cl_io_prepare_write(). + * Release reference acquired by ll_prepare_write(). */ lu_ref_del(&page->cp_reference, "prepare_write", cfs_current()); cl_page_put(env, page); diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index b931dfa..15df5fc 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -506,11 +506,12 @@ static int ll_write_end(struct file *file, struct address_space *mapping, { unsigned from = pos & (PAGE_CACHE_SIZE - 1); int rc; - rc = ll_commit_write(file, page, from, from + copied); + rc = ll_commit_write(file, page, from, from + copied); unlock_page(page); page_cache_release(page); - return rc?rc:copied; + + return rc ?: copied; } #endif