Whamcloud - gitweb
LU-10570 obd: fix statfs handling 58/31158/3
authorJames Simmons <uja.ornl@yahoo.com>
Sun, 4 Feb 2018 19:38:25 +0000 (14:38 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 Feb 2018 03:46:32 +0000 (03:46 +0000)
The function lod_qos_statfs_updates() refreshes statfs
data every N seconds. Taking lq_rw_sem can take a very long
time so the testing for stale stats had to be done again after
taking the semaphore. Now that we are using only seconds
resolution it is more likely that max_age and obd_osfs_age
will be equal compared to when the code was using jiffies.
So only release the lock right away when osfs_age has passed
the max_age.

The comment 'use the value of cfs_time_current + HZ' for
obd_statfs() and obd_statfs_async() needs to updated to
the time64_t case.

Simplify llite_statfs_internal() handling by calculating
max_age inside of llite_statfs_internal(). This makes the
code cleaner.

Change-Id: I22aa5d4d78b30d6480e73998e05ec6582a316d4f
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/31158
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd_class.h
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/lproc_llite.c
lustre/lod/lod_qos.c

index 748cc47..9a93448 100644 (file)
@@ -1074,9 +1074,10 @@ static inline int obd_destroy_export(struct obd_export *exp)
        RETURN(0);
 }
 
-/* @max_age is the oldest time in jiffies that we accept using a cached data.
+/* @max_age is the oldest time in seconds that we accept using a cached data.
  * If the cache is older than @max_age we will get a new value from the
- * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness. */
+ * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
+ */
 static inline int obd_statfs_async(struct obd_export *exp,
                                   struct obd_info *oinfo,
                                   time64_t max_age,
@@ -1118,9 +1119,10 @@ static inline int obd_statfs_async(struct obd_export *exp,
        RETURN(rc);
 }
 
-/* @max_age is the oldest time in jiffies that we accept using a cached data.
+/* @max_age is the oldest time in seconds that we accept using a cached data.
  * If the cache is older than @max_age we will get a new value from the
- * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness. */
+ * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
+ */
 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
                             struct obd_statfs *osfs, time64_t max_age,
                              __u32 flags)
index a249fd9..d1cabaa 100644 (file)
@@ -913,7 +913,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import);
 int ll_setattr(struct dentry *de, struct iattr *attr);
 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
-                      time64_t max_age, __u32 flags);
+                      u32 flags);
 int ll_update_inode(struct inode *inode, struct lustre_md *md);
 int ll_read_inode2(struct inode *inode, void *opaque);
 void ll_delete_inode(struct inode *inode);
index 8cc2f03..acf35e6 100644 (file)
@@ -1773,12 +1773,15 @@ int ll_setattr(struct dentry *de, struct iattr *attr)
 }
 
 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
-                      time64_t max_age, __u32 flags)
+                      u32 flags)
 {
-        struct ll_sb_info *sbi = ll_s2sbi(sb);
-        struct obd_statfs obd_osfs;
-        int rc;
-        ENTRY;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       struct obd_statfs obd_osfs;
+       time64_t max_age;
+       int rc;
+
+       ENTRY;
+       max_age = ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS;
 
         rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, flags);
         if (rc) {
@@ -1831,12 +1834,10 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
        CDEBUG(D_VFSTRACE, "VFS Op: at %llu jiffies\n", get_jiffies_64());
         ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1);
 
-        /* Some amount of caching on the client is allowed */
-        rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                                0);
-        if (rc)
-                return rc;
+       /* Some amount of caching on the client is allowed */
+       rc = ll_statfs_internal(sb, &osfs, 0);
+       if (rc)
+               return rc;
 
         statfs_unpack(sfs, &osfs);
 
index dd3b825..e00664a 100644 (file)
@@ -59,9 +59,7 @@ static int ll_blksize_seq_show(struct seq_file *m, void *v)
        int rc;
 
        LASSERT(sb != NULL);
-       rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                               OBD_STATFS_NODELAY);
+       rc = ll_statfs_internal(sb, &osfs, OBD_STATFS_NODELAY);
        if (!rc)
                seq_printf(m, "%u\n", osfs.os_bsize);
        return rc;
@@ -106,9 +104,7 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v)
        int rc;
 
        LASSERT(sb != NULL);
-       rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                               OBD_STATFS_NODELAY);
+       rc = ll_statfs_internal(sb, &osfs, OBD_STATFS_NODELAY);
        if (!rc) {
                __u32 blk_size = osfs.os_bsize >> 10;
                __u64 result = osfs.os_blocks;
@@ -129,9 +125,7 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v)
        int rc;
 
        LASSERT(sb != NULL);
-       rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                               OBD_STATFS_NODELAY);
+       rc = ll_statfs_internal(sb, &osfs, OBD_STATFS_NODELAY);
        if (!rc) {
                __u32 blk_size = osfs.os_bsize >> 10;
                __u64 result = osfs.os_bfree;
@@ -152,9 +146,7 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v)
        int rc;
 
        LASSERT(sb != NULL);
-       rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                               OBD_STATFS_NODELAY);
+       rc = ll_statfs_internal(sb, &osfs, OBD_STATFS_NODELAY);
        if (!rc) {
                __u32 blk_size = osfs.os_bsize >> 10;
                __u64 result = osfs.os_bavail;
@@ -175,9 +167,7 @@ static int ll_filestotal_seq_show(struct seq_file *m, void *v)
        int rc;
 
        LASSERT(sb != NULL);
-       rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                               OBD_STATFS_NODELAY);
+       rc = ll_statfs_internal(sb, &osfs, OBD_STATFS_NODELAY);
        if (!rc)
                seq_printf(m, "%llu\n", osfs.os_files);
        return rc;
@@ -191,9 +181,7 @@ static int ll_filesfree_seq_show(struct seq_file *m, void *v)
        int rc;
 
        LASSERT(sb != NULL);
-       rc = ll_statfs_internal(sb, &osfs,
-                               ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
-                               OBD_STATFS_NODELAY);
+       rc = ll_statfs_internal(sb, &osfs, OBD_STATFS_NODELAY);
        if (!rc)
                seq_printf(m, "%llu\n", osfs.os_ffree);
        return rc;
index a5b4717..98f8daf 100644 (file)
@@ -276,7 +276,8 @@ void lod_qos_statfs_update(const struct lu_env *env, struct lod_device *lod)
                RETURN_EXIT;
 
        down_write(&lod->lod_qos.lq_rw_sem);
-       if (max_age <= obd->obd_osfs_age)
+
+       if (obd->obd_osfs_age > max_age)
                goto out;
 
        for (i = 0; i < osts->op_count; i++) {