From 05300cbf466d97368b00b49d57839186e5662687 Mon Sep 17 00:00:00 2001 From: Hiroya Nozaki Date: Tue, 16 Jun 2015 14:41:00 +0900 Subject: [PATCH] LU-6732 llite: ll_write_begin/end not passing on errors Because of a implementation of generic_perform_write(), write(2) may return 0 with no errno even if EDQUOT or ENOSPC actually happend in it. This patch fixes the issue with setting a proper errno to ci_result and get it in ll_file_io_generic. Signed-off-by: Hiroya Nozaki Change-Id: I3fc986b57d703ad5fbf41e1ea8182d2d561e8005 Reviewed-on: http://review.whamcloud.com/15302 Tested-by: Maloo Tested-by: Jenkins Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/llite/file.c | 6 ++++++ lustre/llite/rw26.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 9b75dc2..285e360 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1151,6 +1151,12 @@ out: ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_WRITE_BYTES, result); fd->fd_write_failed = false; + } else if (result == 0 && rc == 0) { + rc = io->ci_result; + if (rc < 0) + fd->fd_write_failed = true; + else + fd->fd_write_failed = false; } else if (rc != -ERESTARTSYS) { fd->fd_write_failed = true; } diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 8b37776..ae23b53 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -639,8 +639,10 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, CDEBUG(D_VFSTRACE, "Writing %lu of %d to %d bytes\n", index, from, len); lcc = ll_cl_find(file); - if (lcc == NULL) + if (lcc == NULL) { + io = NULL; GOTO(out, result = -EIO); + } env = lcc->lcc_env; io = lcc->lcc_io; @@ -711,6 +713,8 @@ out: unlock_page(vmpage); page_cache_release(vmpage); } + if (io) + io->ci_result = result; } else { *pagep = vmpage; *fsdata = lcc; @@ -779,6 +783,8 @@ static int ll_write_end(struct file *file, struct address_space *mapping, file->f_flags & O_SYNC || IS_SYNC(file->f_path.dentry->d_inode)) result = vvp_io_write_commit(env, io); + if (result < 0) + io->ci_result = result; RETURN(result >= 0 ? copied : result); } -- 1.8.3.1