Whamcloud - gitweb
b=22703 no error when close if application has known write failure already
authornasf <yong.fan@whamcloud.com>
Wed, 2 Mar 2011 10:23:08 +0000 (18:23 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 10 Mar 2011 17:39:37 +0000 (09:39 -0800)
Do not return error when close if application has known write failure already.

Issues: LU-65
Change-Id: I25b9628fcdd3bf5b7db9d3f8460e06c18226b2e0
Signed-off-by: nasf <yong.fan@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/286
Tested-by: Hudson
Reviewed-by: Jinshan Xiong <jay@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c
lustre/llite/llite_internal.h

index d2c7bb2..957694b 100644 (file)
@@ -830,8 +830,9 @@ static ssize_t ll_file_io_generic(const struct lu_env *env,
                 struct vvp_io_args *args, struct file *file,
                 enum cl_io_type iot, loff_t *ppos, size_t count)
 {
-        struct cl_io       *io;
-        ssize_t             result;
+        struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
+        struct cl_io         *io;
+        ssize_t               result;
         ENTRY;
 
         io = &ccc_env_info(env)->cti_io;
@@ -840,7 +841,6 @@ static ssize_t ll_file_io_generic(const struct lu_env *env,
         if (cl_io_rw_init(env, io, iot, *ppos, count) == 0) {
                 struct vvp_io *vio = vvp_env_io(env);
                 struct ccc_io *cio = ccc_env_io(env);
-                struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
                 int write_sem_locked = 0;
 
                 cio->cui_fd  = LUSTRE_FPRIVATE(file);
@@ -892,6 +892,8 @@ static ssize_t ll_file_io_generic(const struct lu_env *env,
         GOTO(out, result);
 out:
         cl_io_fini(env, io);
+        if (iot == CIT_WRITE)
+                lli->lli_write_rc = result < 0 ? : 0;
         return result;
 }
 
@@ -1892,6 +1894,10 @@ int ll_flush(struct file *file)
         struct lov_stripe_md *lsm = lli->lli_smd;
         int rc, err;
 
+        /* the application should know write failure already. */
+        if (lli->lli_write_rc)
+                return 0;
+
         /* catch async errors that were recorded back when async writeback
          * failed for pages in this mapping. */
         rc = lli->lli_async_rc;
@@ -1965,6 +1971,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                 if (!rc)
                         rc = err;
                 OBDO_FREE(oa);
+                lli->lli_write_rc = err < 0 ? : 0;
         }
 
         RETURN(rc);
index 0e010ba..f9b8691 100644 (file)
@@ -138,6 +138,7 @@ struct ll_inode_info {
 
         /* for writepage() only to communicate to fsync */
         int                     lli_async_rc;
+        int                     lli_write_rc;
 
         struct posix_acl       *lli_posix_acl;