Whamcloud - gitweb
LU-3280 ldlm: suppress useless lock RPC for layout
[fs/lustre-release.git] / lustre / llite / file.c
index e61b696..cfb48ca 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2002, 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/
@@ -2374,7 +2374,7 @@ int ll_flush(struct file *file, fl_owner_t id)
  * Return how many pages have been written.
  */
 int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
-                      enum cl_fsync_mode mode)
+                      enum cl_fsync_mode mode, int ignore_layout)
 {
        struct cl_env_nest nest;
        struct lu_env *env;
@@ -2396,7 +2396,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
 
        io = ccc_env_thread_io(env);
        io->ci_obj = cl_i2info(inode)->lli_clob;
-       io->ci_ignore_layout = 1;
+       io->ci_ignore_layout = ignore_layout;
 
        /* initialize parameters for sync */
        fio = &io->u.ci_fsync;
@@ -2484,7 +2484,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int datasync)
                struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
 
                err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF,
-                               CL_FSYNC_ALL);
+                               CL_FSYNC_ALL, 0);
                if (rc == 0 && err < 0)
                        rc = err;
                if (rc < 0)
@@ -3328,6 +3328,9 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode,
        LDLM_DEBUG(lock, "File %p/"DFID" being reconfigured: %d.\n",
                inode, PFID(&lli->lli_fid), reconf);
 
+       /* in case this is a caching lock and reinstate with new inode */
+       md_set_lock_data(sbi->ll_md_exp, &lockh->cookie, inode, NULL);
+
        lock_res_and_lock(lock);
        lvb_ready = !!(lock->l_flags & LDLM_FL_LVB_READY);
        unlock_res_and_lock(lock);
@@ -3496,8 +3499,6 @@ again:
 
        ll_finish_md_op_data(op_data);
 
-       md_set_lock_data(sbi->ll_md_exp, &it.d.lustre.it_lock_handle, inode, NULL);
-
        mode = it.d.lustre.it_lock_mode;
        it.d.lustre.it_lock_mode = 0;
        ll_intent_drop_lock(&it);