Whamcloud - gitweb
b=23289 set S_NOCMTIME in OSD and remove some mark_inode_dirty
authorJian Yu <jian.yu@oracle.com>
Thu, 2 Dec 2010 13:45:46 +0000 (21:45 +0800)
committerVitaly Fertman <vitaly.fertman@oracle.com>
Fri, 3 Dec 2010 19:33:54 +0000 (22:33 +0300)
o=Liang Zhen
i=andreas.dilger

ldiskfs/kernel_patches/patches/ext4-nocmtime-2.6-rhel5.patch [new file with mode: 0644]
ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h

diff --git a/ldiskfs/kernel_patches/patches/ext4-nocmtime-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-nocmtime-2.6-rhel5.patch
new file mode 100644 (file)
index 0000000..eec475a
--- /dev/null
@@ -0,0 +1,23 @@
+--- linux-2.6.18-194.3.1/fs/ext4/xattr.c       2010-11-23 21:13:35.000000000 -0800
++++ linux-2.6.18-194.3.1-liang/fs/ext4/xattr.c 2010-11-25 20:15:27.000000000 -0800
+@@ -1050,7 +1050,7 @@ ext4_xattr_set_handle(handle_t *handle, 
+       }
+       if (!error) {
+               ext4_xattr_update_super_block(handle, inode->i_sb);
+-              if (!(flags & XATTR_NO_CTIME))
++              if (!IS_NOCMTIME(inode) && !(flags & XATTR_NO_CTIME))
+                       inode->i_ctime = ext4_current_time(inode);
+               if (!value)
+                       EXT4_I(inode)->i_state &= ~EXT4_STATE_NO_EXPAND;
+--- linux-2.6.18-194.3.1/fs/ext4/namei.c       2010-11-23 21:13:35.000000000 -0800
++++ linux-2.6.18-194.3.1-liang/fs/ext4/namei.c 2010-11-25 20:17:25.000000000 -0800
+@@ -1465,7 +1465,8 @@ static int add_dirent_to_buf(handle_t *h
+        * happen is that the times are slightly out of date
+        * and/or different from the directory change time.
+        */
+-      dir->i_mtime = dir->i_ctime = ext4_current_time(dir);
++      if (!IS_NOCMTIME(dir))
++              dir->i_mtime = dir->i_ctime = ext4_current_time(dir);
+       ext4_update_dx_flag(dir);
+       dir->i_version++;
+       ext4_mark_inode_dirty(handle, dir);
index 77c8d9a..de0367b 100644 (file)
@@ -30,3 +30,4 @@ ext4_data_in_dirent.patch
 ext4-disable-mb-cache-rhel5.patch
 ext4-disable-delalloc-rhel5.patch
 ext4-back-dquot-to-rhel54.patch
+ext4-nocmtime-2.6-rhel5.patch
index 27367ec..147fd69 100644 (file)
@@ -347,6 +347,14 @@ static struct inode *osd_iget(struct osd_thread_info *info,
                 CERROR("bad inode %lx\n",inode->i_ino);
                 iput(inode);
                 inode = ERR_PTR(-ENOENT);
+        } else {
+                /* Do not update file c/mtime in ldiskfs.
+                 * NB: we don't have any lock to protect this because we don't
+                 * have reference on osd_object now, but contention with
+                 * another lookup + attr_set can't happen in the tiny window
+                 * between if (...) and set S_NOCMTIME. */
+                if (!(inode->i_flags & S_NOCMTIME))
+                        inode->i_flags |= S_NOCMTIME;
         }
         return inode;
 }
@@ -1403,8 +1411,11 @@ static int osd_inode_setattr(const struct lu_env *env,
         if (bits & LA_RDEV)
                 inode->i_rdev   = attr->la_rdev;
 
-        if (bits & LA_FLAGS)
-                inode->i_flags = ll_ext_to_inode_flags(attr->la_flags);
+        if (bits & LA_FLAGS) {
+                /* always keep S_NOCMTIME */
+                inode->i_flags = ll_ext_to_inode_flags(attr->la_flags) |
+                                 S_NOCMTIME;
+        }
         return 0;
 }
 
@@ -1429,7 +1440,7 @@ static int osd_attr_set(const struct lu_env *env,
         cfs_spin_unlock(&obj->oo_guard);
 
         if (!rc)
-                mark_inode_dirty(obj->oo_inode);
+                obj->oo_inode->i_sb->s_op->dirty_inode(obj->oo_inode);
         return rc;
 }
 
@@ -1509,6 +1520,10 @@ static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj,
         osd_pop_ctxt(save);
 #endif
         if (!IS_ERR(inode)) {
+                /* Do not update file c/mtime in ldiskfs.
+                 * NB: don't need any lock because no contention at this
+                 * early stage */
+                inode->i_flags |= S_NOCMTIME;
                 obj->oo_inode = inode;
                 result = 0;
         } else
@@ -1761,7 +1776,6 @@ static int __osd_xattr_set(const struct lu_env *env, struct dt_object *dt,
         struct inode           *inode    = obj->oo_inode;
         struct osd_thread_info *info     = osd_oti_get(env);
         struct dentry          *dentry   = &info->oti_child_dentry;
-        struct timespec        *t        = &info->oti_time;
         int                     fs_flags = 0;
         int  rc;
 
@@ -1776,14 +1790,8 @@ static int __osd_xattr_set(const struct lu_env *env, struct dt_object *dt,
                 fs_flags |= XATTR_CREATE;
 
         dentry->d_inode = inode;
-        *t = inode->i_ctime;
         rc = inode->i_op->setxattr(dentry, name, buf->lb_buf,
                                    buf->lb_len, fs_flags);
-        /* ctime should not be updated with server-side time. */
-        cfs_spin_lock(&obj->oo_guard);
-        inode->i_ctime = *t;
-        cfs_spin_unlock(&obj->oo_guard);
-        mark_inode_dirty(inode);
         return rc;
 }
 
@@ -1984,7 +1992,7 @@ static void osd_object_ref_add(const struct lu_env *env,
         LASSERT(inode->i_nlink < LDISKFS_LINK_MAX);
         inode->i_nlink++;
         cfs_spin_unlock(&obj->oo_guard);
-        mark_inode_dirty(inode);
+        inode->i_sb->s_op->dirty_inode(inode);
         LINVRNT(osd_invariant(obj));
 }
 
@@ -2007,7 +2015,7 @@ static void osd_object_ref_del(const struct lu_env *env,
         LASSERT(inode->i_nlink > 0);
         inode->i_nlink--;
         cfs_spin_unlock(&obj->oo_guard);
-        mark_inode_dirty(inode);
+        inode->i_sb->s_op->dirty_inode(inode);
         LINVRNT(osd_invariant(obj));
 }
 
@@ -2088,7 +2096,6 @@ static int osd_xattr_del(const struct lu_env *env,
         struct inode           *inode  = obj->oo_inode;
         struct osd_thread_info *info   = osd_oti_get(env);
         struct dentry          *dentry = &info->oti_obj_dentry;
-        struct timespec        *t      = &info->oti_time;
         int                     rc;
 
         LASSERT(dt_object_exists(dt));
@@ -2100,13 +2107,7 @@ static int osd_xattr_del(const struct lu_env *env,
                 return -EACCES;
 
         dentry->d_inode = inode;
-        *t = inode->i_ctime;
         rc = inode->i_op->removexattr(dentry, name);
-        /* ctime should not be updated with server-side time. */
-        cfs_spin_lock(&obj->oo_guard);
-        inode->i_ctime = *t;
-        cfs_spin_unlock(&obj->oo_guard);
-        mark_inode_dirty(inode);
         return rc;
 }
 
@@ -2755,20 +2756,8 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
         cfs_down_write(&obj->oo_ext_idx_sem);
         bh = ll_ldiskfs_find_entry(dir, dentry, &de);
         if (bh) {
-                struct osd_thread_info *oti = osd_oti_get(env);
-                struct timespec *ctime = &oti->oti_time;
-                struct timespec *mtime = &oti->oti_time2;
-
-                *ctime = dir->i_ctime;
-                *mtime = dir->i_mtime;
                 rc = ldiskfs_delete_entry(oh->ot_handle,
                                 dir, de, bh);
-                /* xtime should not be updated with server-side time. */
-                cfs_spin_lock(&obj->oo_guard);
-                dir->i_ctime = *ctime;
-                dir->i_mtime = *mtime;
-                cfs_spin_unlock(&obj->oo_guard);
-                mark_inode_dirty(dir);
                 brelse(bh);
         } else
                 rc = -ENOENT;
@@ -3163,13 +3152,6 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
 
         child = osd_object_find(env, dt, fid);
         if (!IS_ERR(child)) {
-                struct inode *inode = obj->oo_inode;
-                struct osd_thread_info *oti = osd_oti_get(env);
-                struct timespec *ctime = &oti->oti_time;
-                struct timespec *mtime = &oti->oti_time2;
-
-                *ctime = inode->i_ctime;
-                *mtime = inode->i_mtime;
 #ifdef HAVE_QUOTA_SUPPORT
                 if (ignore_quota)
                         cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
@@ -3183,12 +3165,6 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
                 cfs_curproc_cap_unpack(save);
 #endif
                 osd_object_put(env, child);
-                /* xtime should not be updated with server-side time. */
-                cfs_spin_lock(&obj->oo_guard);
-                inode->i_ctime = *ctime;
-                inode->i_mtime = *mtime;
-                cfs_spin_unlock(&obj->oo_guard);
-                mark_inode_dirty(inode);
         } else {
                 rc = PTR_ERR(child);
         }
index 97b87be..ea559e3 100644 (file)
@@ -227,7 +227,6 @@ struct osd_thread_info {
          */
         struct txn_param       oti_txn;
         struct timespec        oti_time;
-        struct timespec        oti_time2;
         /*
          * XXX temporary: fake struct file for osd_object_sync
          */