Whamcloud - gitweb
LU-1943 osd: fix lost functionality in OFD and OSD
authorMikhail Pershin <tappro@whamcloud.com>
Fri, 14 Sep 2012 21:39:00 +0000 (01:39 +0400)
committerAndreas Dilger <adilger@whamcloud.com>
Mon, 1 Oct 2012 06:53:42 +0000 (02:53 -0400)
- restore ofd_fmd_expire() in ofd_ping()
- set OS_STATE_READONLY in osd_statfs()
- fix readcache initialization and add lprocfs entries for it
- fix test_19 to work with OSD if OFD is used

Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Change-Id: I357b28d8d5de1e48c55b12faa4d31ac75dbd5f66
Reviewed-on: http://review.whamcloud.com/3991
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
lustre/ofd/ofd_obd.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_lproc.c
lustre/tests/sanityn.sh

index 0459ad8..820cfff 100644 (file)
@@ -1356,6 +1356,7 @@ static int ofd_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 
 static int ofd_ping(const struct lu_env *env, struct obd_export *exp)
 {
+       ofd_fmd_expire(exp);
        return 0;
 }
 
index 185f348..51365cd 100644 (file)
@@ -904,6 +904,8 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d,
                if (likely(result == 0)) { /* N.B. statfs can't really fail */
                        osd->od_osfs_age = cfs_time_current_64();
                        statfs_pack(&osd->od_statfs, ksfs);
+                       if (sb->s_flags & MS_RDONLY)
+                               sfs->os_state = OS_STATE_READONLY;
                }
        }
 
@@ -4474,6 +4476,7 @@ static int osd_device_init0(const struct lu_env *env,
 
        o->od_read_cache = 1;
        o->od_writethrough_cache = 1;
+       o->od_readcache_max_filesize = OSD_MAX_CACHE_SIZE;
 
        rc = osd_mount(env, o, cfg);
        if (rc)
index 54d6185..86778fc 100644 (file)
@@ -720,6 +720,8 @@ static inline int osd_invariant(const struct osd_object *obj)
 #define osd_invariant(obj) (1)
 #endif
 
+#define OSD_MAX_CACHE_SIZE OBD_OBJECT_EOF
+
 extern const struct dt_index_operations osd_otable_ops;
 
 static inline int osd_oi_fid2idx(struct osd_device *dev,
index 4e2cb99..b88128f 100644 (file)
@@ -314,7 +314,7 @@ void osd_lprocfs_time_end(const struct lu_env *env, struct osd_device *osd,
 static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, int count,
                                 int *eof, void *data)
 {
-        struct obd_device *osd = data;
+       struct osd_device *osd = osd_dt_dev(data);
 
         LASSERT(osd != NULL);
         return snprintf(page, count, "ldiskfs\n");
@@ -336,13 +336,73 @@ static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count,
                        mnt_get_devname(osd->od_mnt));
 }
 
+static int lprocfs_osd_rd_cache(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct osd_device *osd = osd_dt_dev(data);
+
+       LASSERT(osd != NULL);
+       if (unlikely(osd->od_mnt == NULL))
+               return -EINPROGRESS;
+
+       return snprintf(page, count, "%u\n", osd->od_read_cache);
+}
+
+static int lprocfs_osd_wr_cache(struct file *file, const char *buffer,
+                               unsigned long count, void *data)
+{
+       struct osd_device       *osd = osd_dt_dev(data);
+       int                      val, rc;
+
+       LASSERT(osd != NULL);
+       if (unlikely(osd->od_mnt == NULL))
+               return -EINPROGRESS;
+
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc)
+               return rc;
+
+       osd->od_read_cache = !!val;
+       return count;
+}
+
+static int lprocfs_osd_rd_wcache(char *page, char **start, off_t off,
+                                int count, int *eof, void *data)
+{
+       struct osd_device *osd = osd_dt_dev(data);
+
+       LASSERT(osd != NULL);
+       if (unlikely(osd->od_mnt == NULL))
+               return -EINPROGRESS;
+
+       return snprintf(page, count, "%u\n", osd->od_writethrough_cache);
+}
+
+static int lprocfs_osd_wr_wcache(struct file *file, const char *buffer,
+                                unsigned long count, void *data)
+{
+       struct osd_device       *osd = osd_dt_dev(data);
+       int                      val, rc;
+
+       LASSERT(osd != NULL);
+       if (unlikely(osd->od_mnt == NULL))
+               return -EINPROGRESS;
+
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc)
+               return rc;
+
+       osd->od_writethrough_cache = !!val;
+       return count;
+}
+
 static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer,
                                     unsigned long count, void *data)
 {
-       struct osd_device *osd = osd_dt_dev(data);
-       struct dt_device  *dt = data;
-       struct lu_env      env;
-       int rc;
+       struct osd_device       *osd = osd_dt_dev(data);
+       struct dt_device        *dt = data;
+       struct lu_env            env;
+       int                      rc;
 
        LASSERT(osd != NULL);
        if (unlikely(osd->od_mnt == NULL))
@@ -385,7 +445,7 @@ static int lprocfs_osd_wr_pdo(struct file *file, const char *buffer,
 static int lprocfs_osd_rd_auto_scrub(char *page, char **start, off_t off,
                                     int count, int *eof, void *data)
 {
-       struct osd_device *dev = data;
+       struct osd_device *dev = osd_dt_dev(data);
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
@@ -398,7 +458,7 @@ static int lprocfs_osd_rd_auto_scrub(char *page, char **start, off_t off,
 static int lprocfs_osd_wr_auto_scrub(struct file *file, const char *buffer,
                                     unsigned long count, void *data)
 {
-       struct osd_device *dev = data;
+       struct osd_device *dev = osd_dt_dev(data);
        int val, rc;
 
        LASSERT(dev != NULL);
@@ -416,7 +476,7 @@ static int lprocfs_osd_wr_auto_scrub(struct file *file, const char *buffer,
 static int lprocfs_osd_rd_oi_scrub(char *page, char **start, off_t off,
                                   int count, int *eof, void *data)
 {
-       struct osd_device *dev = data;
+       struct osd_device *dev = osd_dt_dev(data);
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
@@ -426,6 +486,40 @@ static int lprocfs_osd_rd_oi_scrub(char *page, char **start, off_t off,
        return osd_scrub_dump(dev, page, count);
 }
 
+int lprocfs_osd_rd_readcache(char *page, char **start, off_t off, int count,
+                            int *eof, void *data)
+{
+       struct osd_device       *osd = osd_dt_dev(data);
+       int                      rc;
+
+       LASSERT(osd != NULL);
+       if (unlikely(osd->od_mnt == NULL))
+               return -EINPROGRESS;
+
+       rc = snprintf(page, count, LPU64"\n", osd->od_readcache_max_filesize);
+       return rc;
+}
+
+int lprocfs_osd_wr_readcache(struct file *file, const char *buffer,
+                            unsigned long count, void *data)
+{
+       struct osd_device       *osd = osd_dt_dev(data);
+       __u64                    val;
+       int                      rc;
+
+       LASSERT(osd != NULL);
+       if (unlikely(osd->od_mnt == NULL))
+               return -EINPROGRESS;
+
+       rc = lprocfs_write_u64_helper(buffer, count, &val);
+       if (rc)
+               return rc;
+
+       osd->od_readcache_max_filesize = val > OSD_MAX_CACHE_SIZE ?
+                                        OSD_MAX_CACHE_SIZE : val;
+       return count;
+}
+
 struct lprocfs_vars lprocfs_osd_obd_vars[] = {
         { "blocksize",       lprocfs_osd_rd_blksize,     0, 0 },
         { "kbytestotal",     lprocfs_osd_rd_kbytestotal, 0, 0 },
@@ -442,6 +536,12 @@ struct lprocfs_vars lprocfs_osd_obd_vars[] = {
        { "auto_scrub",      lprocfs_osd_rd_auto_scrub,
                             lprocfs_osd_wr_auto_scrub,  0 },
        { "oi_scrub",        lprocfs_osd_rd_oi_scrub,    0, 0 },
+       { "force_sync",         0, lprocfs_osd_wr_force_sync },
+       { "read_cache_enable",  lprocfs_osd_rd_cache, lprocfs_osd_wr_cache, 0 },
+       { "writethrough_cache_enable",  lprocfs_osd_rd_wcache,
+                                       lprocfs_osd_wr_wcache, 0 },
+       { "readcache_max_filesize",     lprocfs_osd_rd_readcache,
+                                       lprocfs_osd_wr_readcache, 0 },
        { 0 }
 };
 
index 7f06570..fbc8bf7 100644 (file)
@@ -368,26 +368,33 @@ test_18() {
 run_test 18 "mmap sanity check ================================="
 
 test_19() { # bug3811
-       [ -d /proc/fs/lustre/obdfilter ] || return 0
+       local node=$(facet_active_host ost1)
 
-       MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
-       lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
-       dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
-       SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
-       cp $TMP/f19b $DIR1/f19b
+       # check whether obdfilter is cache capable at all
+       if ! get_obdfilter_param $node '' read_cache_enable >/dev/null; then
+               echo "not cache-capable obdfilter"
+               return 0
+       fi
+
+       local MAX=$(get_obdfilter_param $node '' readcache_max_filesize | \
+                   head -n 1)
+       set_obdfilter_param $node '' readcache_max_filesize 4096
+       dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
+       local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
+       cp $TMP/$tfile $DIR1/$tfile
        for i in `seq 1 20`; do
-               [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
+               [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
                cancel_lru_locks osc > /dev/null
-               cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
-               cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
+               cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
+               cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
                wait
-               [ "`cat $TMP/sum1`" = "$SUM" ] || \
-                       error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
-               [ "`cat $TMP/sum2`" = "$SUM" ] || \
-                       error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
+               [ "$(cat $TMP/sum1)" = "$SUM" ] || \
+                       error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
+               [ "$(cat $TMP/sum2)" = "$SUM" ] || \
+                       error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
        done
-       lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
-       rm $DIR1/f19b
+       set_obdfilter_param $node '' readcache_max_filesize $MAX
+       rm $DIR1/$tfile
 }
 run_test 19 "test concurrent uncached read races ==============="