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");
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))
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))
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);
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))
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 },
{ "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 }
};
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 ==============="