Whamcloud - gitweb
LU-1146 build: batch update copyright messages
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_lproc.c
index df25006..34a3a20 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -121,7 +123,12 @@ int lprocfs_osd_rd_blksize(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
 {
         struct osd_device *osd = data;
-        int rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
+        int rc;
+
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
+        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
         if (!rc) {
                 *eof = 1;
                 rc = snprintf(page, count, "%ld\n", osd->od_kstatfs.f_bsize);
@@ -133,7 +140,12 @@ int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off, int count,
                                int *eof, void *data)
 {
         struct osd_device *osd = data;
-        int rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
+        int rc;
+
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
+        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
         if (!rc) {
                 __u32 blk_size = osd->od_kstatfs.f_bsize >> 10;
                 __u64 result = osd->od_kstatfs.f_blocks;
@@ -151,7 +163,12 @@ int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off, int count,
                               int *eof, void *data)
 {
         struct osd_device *osd = data;
-        int rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
+        int rc;
+
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
+        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
         if (!rc) {
                 __u32 blk_size = osd->od_kstatfs.f_bsize >> 10;
                 __u64 result = osd->od_kstatfs.f_bfree;
@@ -169,7 +186,12 @@ int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off, int count,
                                int *eof, void *data)
 {
         struct osd_device *osd = data;
-        int rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
+        int rc;
+
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
+        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
         if (!rc) {
                 __u32 blk_size = osd->od_kstatfs.f_bsize >> 10;
                 __u64 result = osd->od_kstatfs.f_bavail;
@@ -187,7 +209,12 @@ int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off, int count,
                               int *eof, void *data)
 {
         struct osd_device *osd = data;
-        int rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
+        int rc;
+
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
+        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
         if (!rc) {
                 *eof = 1;
                 rc = snprintf(page, count, LPU64"\n", osd->od_kstatfs.f_files);
@@ -200,7 +227,12 @@ int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off, int count,
                              int *eof, void *data)
 {
         struct osd_device *osd = data;
-        int rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
+        int rc;
+
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
+        rc = osd_statfs(NULL, &osd->od_dt_dev, &osd->od_kstatfs);
         if (!rc) {
                 *eof = 1;
                 rc = snprintf(page, count, LPU64"\n", osd->od_kstatfs.f_ffree);
@@ -223,6 +255,9 @@ static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count,
         struct osd_device *osd = data;
 
         LASSERT(osd != NULL);
+        if (unlikely(osd->od_mount == NULL))
+                return -EINPROGRESS;
+
         LASSERT(osd->od_mount->lmi_mnt->mnt_devname);
         *eof = 1;
 
@@ -230,6 +265,31 @@ static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count,
                         osd->od_mount->lmi_mnt->mnt_devname);
 }
 
+#ifdef HAVE_LDISKFS_PDO
+static int lprocfs_osd_rd_pdo(char *page, char **start, off_t off, int count,
+                              int *eof, void *data)
+{
+        *eof = 1;
+
+        return snprintf(page, count, "%s\n", ldiskfs_pdo ? "ON" : "OFF");
+}
+
+static int lprocfs_osd_wr_pdo(struct file *file, const char *buffer,
+                              unsigned long count, void *data)
+{
+        int     pdo;
+        int     rc;
+
+        rc = lprocfs_write_helper(buffer, count, &pdo);
+        if (rc != 0)
+                return rc;
+
+        ldiskfs_pdo = !!pdo;
+
+        return count;
+}
+#endif
+
 struct lprocfs_vars lprocfs_osd_obd_vars[] = {
         { "blocksize",       lprocfs_osd_rd_blksize,     0, 0 },
         { "kbytestotal",     lprocfs_osd_rd_kbytestotal, 0, 0 },
@@ -239,6 +299,9 @@ struct lprocfs_vars lprocfs_osd_obd_vars[] = {
         { "filesfree",       lprocfs_osd_rd_filesfree,   0, 0 },
         { "fstype",          lprocfs_osd_rd_fstype,      0, 0 },
         { "mntdev",          lprocfs_osd_rd_mntdev,      0, 0 },
+#ifdef HAVE_LDISKFS_PDO
+        { "pdo",             lprocfs_osd_rd_pdo, lprocfs_osd_wr_pdo, 0 },
+#endif
         { 0 }
 };