From ea4f3303604ecd734114d794f7e1ab2680bbc1b5 Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Mon, 3 May 2010 14:27:41 +0400 Subject: [PATCH] b=22360 make errno return possible in close(2) i=Oleg Drokin i=Alexander Zarochentsev use vfs ->flush callback to return any pending async errors. --- lustre/ChangeLog | 4 ++++ lustre/llite/file.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 7f963e2..93955c9 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -286,6 +286,10 @@ Details : dq_flags(struct dquot) access is not properly locked which could lead to certain inconsistencies when accessing it using non-atomic bit operations like __set_bit in do_set_dqblk. +Severity : normal +Bugzilla : 22360 +Description: return any pending async errors in close(2) using flush callback + ------------------------------------------------------------------------------- 2010-01-29 Sun Microsystems, Inc. diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 7f42bff..33d562c 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3029,6 +3029,26 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) RETURN(retval); } +int ll_flush(struct file *file, fl_owner_t id) +{ + struct inode *inode = file->f_dentry->d_inode; + struct ll_inode_info *lli = ll_i2info(inode); + struct lov_stripe_md *lsm = lli->lli_smd; + int rc, err; + + /* catch async errors that were recorded back when async writeback + * failed for pages in this mapping. */ + rc = lli->lli_async_rc; + lli->lli_async_rc = 0; + if (lsm) { + err = lov_test_and_clear_async_rc(lsm); + if (rc == 0) + rc = err; + } + + return rc; +} + int ll_fsync(struct file *file, struct dentry *dentry, int data) { struct inode *inode = dentry->d_inode; @@ -3582,6 +3602,7 @@ struct file_operations ll_file_operations = { .sendfile = ll_file_sendfile, #endif .fsync = ll_fsync, + .flush = ll_flush }; struct file_operations ll_file_operations_flock = { @@ -3609,6 +3630,7 @@ struct file_operations ll_file_operations_flock = { .sendfile = ll_file_sendfile, #endif .fsync = ll_fsync, + .flush = ll_flush, #ifdef HAVE_F_OP_FLOCK .flock = ll_file_flock, #endif @@ -3641,6 +3663,7 @@ struct file_operations ll_file_operations_noflock = { .sendfile = ll_file_sendfile, #endif .fsync = ll_fsync, + .flush = ll_flush, #ifdef HAVE_F_OP_FLOCK .flock = ll_file_noflock, #endif -- 1.8.3.1