Whamcloud - gitweb
LU-4802 tests: Create non-stripe dir for cross-MDT opration
[fs/lustre-release.git] / lustre / mdd / mdd_lproc.c
index 4d64e43..de379b3 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -103,7 +103,7 @@ static int lprocfs_wr_atime_diff(struct file *file, const char *buffer,
         if (count > (sizeof(kernbuf) - 1))
                 return -EINVAL;
 
-        if (cfs_copy_from_user(kernbuf, buffer, count))
+       if (copy_from_user(kernbuf, buffer, count))
                 return -EFAULT;
 
         kernbuf[count] = '\0';
@@ -144,29 +144,29 @@ static int lprocfs_rd_changelog_mask(char *page, char **start, off_t off,
 }
 
 static int lprocfs_wr_changelog_mask(struct file *file, const char *buffer,
-                                     unsigned long count, void *data)
+                                    unsigned long count, void *data)
 {
-        struct mdd_device *mdd = data;
-        char *kernbuf;
-        int rc;
-        ENTRY;
-
-        if (count >= CFS_PAGE_SIZE)
-                RETURN(-EINVAL);
-        OBD_ALLOC(kernbuf, CFS_PAGE_SIZE);
-        if (kernbuf == NULL)
-                RETURN(-ENOMEM);
-        if (cfs_copy_from_user(kernbuf, buffer, count))
-                GOTO(out, rc = -EFAULT);
-        kernbuf[count] = 0;
-
-        rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask,
-                          CHANGELOG_MINMASK, CHANGELOG_ALLMASK);
-        if (rc == 0)
-                rc = count;
+       struct mdd_device *mdd = data;
+       char *kernbuf;
+       int rc;
+       ENTRY;
+
+       if (count >= PAGE_CACHE_SIZE)
+               RETURN(-EINVAL);
+       OBD_ALLOC(kernbuf, PAGE_CACHE_SIZE);
+       if (kernbuf == NULL)
+               RETURN(-ENOMEM);
+       if (copy_from_user(kernbuf, buffer, count))
+               GOTO(out, rc = -EFAULT);
+       kernbuf[count] = 0;
+
+       rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask,
+                         CHANGELOG_MINMASK, CHANGELOG_ALLMASK);
+       if (rc == 0)
+               rc = count;
 out:
-        OBD_FREE(kernbuf, CFS_PAGE_SIZE);
-        return rc;
+       OBD_FREE(kernbuf, PAGE_CACHE_SIZE);
+       return rc;
 }
 
 struct cucb_data {
@@ -272,15 +272,14 @@ static int lprocfs_rd_lfsck_speed_limit(char *page, char **start, off_t off,
 
        LASSERT(mdd != NULL);
        *eof = 1;
-       return snprintf(page, count, "%u\n",
-                       mdd->mdd_lfsck.ml_bookmark_ram.lb_speed_limit);
+
+       return lfsck_get_speed(mdd->mdd_bottom, page, count);
 }
 
 static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer,
                                        unsigned long count, void *data)
 {
        struct mdd_device *mdd = data;
-       struct md_lfsck *lfsck;
        __u32 val;
        int rc;
 
@@ -289,39 +288,63 @@ static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer,
        if (rc != 0)
                return rc;
 
-       lfsck = &mdd->mdd_lfsck;
-       if (val != lfsck->ml_bookmark_ram.lb_speed_limit) {
-               struct lu_env env;
+       rc = lfsck_set_speed(mdd->mdd_bottom, val);
+       return rc != 0 ? rc : count;
+}
 
-               rc = lu_env_init(&env, LCT_MD_THREAD | LCT_DT_THREAD);
-               if (rc != 0)
-                       return rc;
+static int lprocfs_rd_lfsck_async_windows(char *page, char **start, off_t off,
+                                         int count, int *eof, void *data)
+{
+       struct mdd_device *mdd = data;
+       int                rc;
+
+       LASSERT(mdd != NULL);
+       *eof = 1;
+
+       rc = lfsck_get_windows(mdd->mdd_bottom, page, count);
+
+       return rc != 0 ? rc : count;
+}
+
+static int lprocfs_wr_lfsck_async_windows(struct file *file, const char *buffer,
+                                         unsigned long count, void *data)
+{
+       struct mdd_device *mdd = data;
+       __u32              val;
+       int                rc;
+
+       LASSERT(mdd != NULL);
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc == 0)
+               rc = lfsck_set_windows(mdd->mdd_bottom, val);
 
-               rc = mdd_lfsck_set_speed(&env, lfsck, val);
-               lu_env_fini(&env);
-       }
        return rc != 0 ? rc : count;
 }
 
 static int lprocfs_rd_lfsck_namespace(char *page, char **start, off_t off,
                                      int count, int *eof, void *data)
 {
-       struct lu_env env;
        struct mdd_device *mdd = data;
        int rc;
 
        LASSERT(mdd != NULL);
        *eof = 1;
 
-       rc = lu_env_init(&env, LCT_MD_THREAD | LCT_DT_THREAD);
-       if (rc != 0)
-               return rc;
-
-       rc = mdd_lfsck_dump(&env, &mdd->mdd_lfsck, LT_NAMESPACE, page, count);
-       lu_env_fini(&env);
+       rc = lfsck_dump(mdd->mdd_bottom, page, count, LT_NAMESPACE);
        return rc;
 }
 
+static int lprocfs_rd_lfsck_layout(char *page, char **start, off_t off,
+                                  int count, int *eof, void *data)
+{
+       struct mdd_device *mdd = data;
+
+       LASSERT(mdd != NULL);
+       *eof = 1;
+
+       return lfsck_dump(mdd->mdd_bottom, page, count, LT_LAYOUT);
+}
+
 static struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
         { "atime_diff",      lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 },
         { "changelog_mask",  lprocfs_rd_changelog_mask,
@@ -330,7 +353,10 @@ static struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
         { "sync_permission", lprocfs_rd_sync_perm, lprocfs_wr_sync_perm, 0 },
        { "lfsck_speed_limit", lprocfs_rd_lfsck_speed_limit,
                               lprocfs_wr_lfsck_speed_limit, 0 },
+       { "lfsck_async_windows", lprocfs_rd_lfsck_async_windows,
+                                lprocfs_wr_lfsck_async_windows, 0 },
        { "lfsck_namespace", lprocfs_rd_lfsck_namespace, 0, 0 },
+       { "lfsck_layout", lprocfs_rd_lfsck_layout, 0, 0 },
        { 0 }
 };