Whamcloud - gitweb
LU-3409 llite: silence lockdep warning in ll_md_blocking_ast
[fs/lustre-release.git] / lustre / llite / vvp_io.c
index 9020d77..3a64517 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -1010,6 +1010,7 @@ static int vvp_io_commit_write(const struct lu_env *env,
         struct cl_page    *pg     = slice->cpl_page;
         struct inode      *inode  = ccc_object_inode(obj);
         struct ll_sb_info *sbi    = ll_i2sbi(inode);
+       struct ll_inode_info *lli = ll_i2info(inode);
         cfs_page_t        *vmpage = cp->cpg_page;
 
         int    result;
@@ -1090,6 +1091,20 @@ static int vvp_io_commit_write(const struct lu_env *env,
         }
         ll_stats_ops_tally(sbi, tallyop, 1);
 
+       /* Inode should be marked DIRTY even if no new page was marked DIRTY
+        * because page could have been not flushed between 2 modifications.
+        * It is important the file is marked DIRTY as soon as the I/O is done
+        * Indeed, when cache is flushed, file could be already closed and it
+        * is too late to warn the MDT.
+        * It is acceptable that file is marked DIRTY even if I/O is dropped
+        * for some reasons before being flushed to OST.
+        */
+       if (result == 0) {
+               spin_lock(&lli->lli_lock);
+               lli->lli_flags |= LLIF_DATA_MODIFIED;
+               spin_unlock(&lli->lli_lock);
+       }
+
         size = cl_offset(obj, pg->cp_index) + to;
 
        ll_inode_size_lock(inode);
@@ -1199,8 +1214,19 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj,
        /* Enqueue layout lock and get layout version. We need to do this
         * even for operations requiring to open file, such as read and write,
         * because it might not grant layout lock in IT_OPEN. */
-       if (result == 0 && !io->ci_ignore_layout)
+       if (result == 0 && !io->ci_ignore_layout) {
                result = ll_layout_refresh(inode, &cio->cui_layout_gen);
+               if (result == -ENOENT)
+                       /* If the inode on MDS has been removed, but the objects
+                        * on OSTs haven't been destroyed (async unlink), layout
+                        * fetch will return -ENOENT, we'd ingore this error
+                        * and continue with dirty flush. LU-3230. */
+                       result = 0;
+               if (result < 0)
+                       CERROR("%s: refresh file layout " DFID " error %d.\n",
+                               ll_get_fsname(inode->i_sb, NULL, 0),
+                               PFID(lu_object_fid(&obj->co_lu)), result);
+       }
 
        RETURN(result);
 }