From 3b2d496affc294e86744ab9b1c1014f0ce81bb3e Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Wed, 19 Sep 2012 16:37:22 +0300 Subject: [PATCH] LU-1962 util: Add --lazy flag to lfs df add --lazy flag to lfs df it allows to skip unavailable OSTs and report "Resource temporarily unavailable" for them Xyratex-bug-id: MRP-583 Signed-off-by: Andriy Skulysh Reviewed-by: Alexander Boyko Reviewed-by: Alexey Lyashkov Change-Id: Idb6b728b52c5fa1590d07201700a3fad0ef7cc78 Reviewed-on: http://review.whamcloud.com/4007 Reviewed-by: Yu Jian Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_user.h | 1 + lustre/llite/llite_lib.c | 8 +++++--- lustre/lov/lov_obd.c | 4 +++- lustre/tests/conf-sanity.sh | 12 ++++++++++++ lustre/utils/lfs.c | 17 ++++++++++++----- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index ca7c4b2..42f1bd0 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -157,6 +157,7 @@ struct obd_statfs { #define LL_STATFS_LMV 1 #define LL_STATFS_LOV 2 +#define LL_STATFS_NODELAY 4 #define IOC_MDC_TYPE 'i' #define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index b30165a..f3210d7 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2182,6 +2182,7 @@ int ll_obd_statfs(struct inode *inode, void *arg) char *buf = NULL; struct obd_ioctl_data *data = NULL; __u32 type; + __u32 flags; int len = 0, rc; if (!inode || !(sbi = ll_i2sbi(inode))) @@ -2203,14 +2204,15 @@ int ll_obd_statfs(struct inode *inode, void *arg) GOTO(out_statfs, rc = -EINVAL); memcpy(&type, data->ioc_inlbuf1, sizeof(__u32)); - if (type == LL_STATFS_LMV) + if (type & LL_STATFS_LMV) exp = sbi->ll_md_exp; - else if (type == LL_STATFS_LOV) + else if (type & LL_STATFS_LOV) exp = sbi->ll_dt_exp; else GOTO(out_statfs, rc = -ENODEV); - rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL); + flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0; + rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags); if (rc) GOTO(out_statfs, rc); out_statfs: diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index a725351..098bce5 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2035,6 +2035,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct obd_device *osc_obd; struct obd_statfs stat_buf = {0}; __u32 index; + __u32 flags; memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); if ((index >= count)) @@ -2056,10 +2057,11 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, (int) sizeof(struct obd_uuid)))) RETURN(-EFAULT); + flags = uarg ? *(__u32*)uarg : 0; /* got statfs data */ rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - 0); + flags); if (rc) RETURN(rc); if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 882e391..e0df8b8 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -2971,6 +2971,18 @@ test_63() { } run_test 63 "Verify each page can at least hold 3 ldisk inodes" +test_64() { + start_mds + start_ost + start_ost2 || error "Unable to start second ost" + mount_client $MOUNT || error "Unable to mount client" + stop_ost2 || error "Unable to stop second ost" + echo "$LFS df" + $LFS df --lazy || error "lfs df failed" + cleanup || return $? +} +run_test 64 "check lfs df --lazy " + if ! combined_mgs_mds ; then stop mgs fi diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 2b60ec4..902752d 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -168,7 +168,7 @@ command_t cmdlist[] = { {"df", lfs_df, 0, "report filesystem disk space usage or inodes usage" "of each MDS and all OSDs or a batch belonging to a specific pool .\n" - "Usage: df [-i] [-h] [--pool|-p [.] [path]"}, + "Usage: df [-i] [-h] [--lazy|-l] [--pool|-p [.] [path]"}, {"getname", lfs_getname, 0, "list instances and specified mount points " "[for specified path only]\n" "Usage: getname [-h]|[path ...] "}, @@ -1214,7 +1214,8 @@ struct ll_stat_type { char *st_name; }; -static int mntdf(char *mntdir, char *fsname, char *pool, int ishow, int cooked) +static int mntdf(char *mntdir, char *fsname, char *pool, int ishow, + int cooked, int lazy) { struct obd_statfs stat_buf, sum = { .os_bsize = 1 }; struct obd_uuid uuid_buf; @@ -1224,6 +1225,7 @@ static int mntdf(char *mntdir, char *fsname, char *pool, int ishow, int cooked) { 0, NULL } }; struct ll_stat_type *tp; __u32 index; + __u32 type; int rc; if (pool) { @@ -1251,7 +1253,8 @@ static int mntdf(char *mntdir, char *fsname, char *pool, int ishow, int cooked) for (index = 0; ; index++) { memset(&stat_buf, 0, sizeof(struct obd_statfs)); memset(&uuid_buf, 0, sizeof(struct obd_uuid)); - rc = llapi_obd_statfs(mntdir, tp->st_op, index, + type = lazy ? tp->st_op | LL_STATFS_NODELAY : tp->st_op; + rc = llapi_obd_statfs(mntdir, type, index, &stat_buf, &uuid_buf); if (rc == -ENODEV) break; @@ -1300,15 +1303,17 @@ static int lfs_df(int argc, char **argv) { char mntdir[PATH_MAX] = {'\0'}, path[PATH_MAX] = {'\0'}; int ishow = 0, cooked = 0; + int lazy = 0; int c, rc = 0, index = 0; char fsname[PATH_MAX] = "", *pool_name = NULL; struct option long_opts[] = { {"pool", required_argument, 0, 'p'}, + {"lazy", 0, 0, 'l'}, {0, 0, 0, 0} }; optind = 0; - while ((c = getopt_long(argc, argv, "hip:", long_opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "hilp:", long_opts, NULL)) != -1) { switch (c) { case 'i': ishow = 1; @@ -1316,6 +1321,8 @@ static int lfs_df(int argc, char **argv) case 'h': cooked = 1; break; + case 'l': + lazy = 1; case 'p': pool_name = optarg; break; @@ -1335,7 +1342,7 @@ static int lfs_df(int argc, char **argv) if (mntdir[0] == '\0') continue; - rc = mntdf(mntdir, fsname, pool_name, ishow, cooked); + rc = mntdf(mntdir, fsname, pool_name, ishow, cooked, lazy); if (rc || path[0] != '\0') break; fsname[0] = '\0'; /* avoid matching in next loop */ -- 1.8.3.1