Whamcloud - gitweb
LU-354 test: Change dev_set_rdonly() check to warning
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 9 Mar 2012 23:08:55 +0000 (15:08 -0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 29 Mar 2012 04:45:22 +0000 (00:45 -0400)
The dev_set_rdonly() symbol is only required to fence I/O
from the underlying device for testing.  This patch is not
strictly required to build a lustre release.

In addition, this change updates the dt_ro callback to
potentially return an error code.

Change-Id: I35b0a120087845e2a57c9df6c3e1de5b9e4b6ff7
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-on: http://review.whamcloud.com/1872
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
12 files changed:
lustre/autoconf/lustre-core.m4
lustre/include/dt_object.h
lustre/include/linux/lvfs_linux.h
lustre/include/obd_support.h
lustre/kernel_patches/patches/dev_read_only-2.6.18-vanilla.patch
lustre/kernel_patches/patches/dev_read_only-2.6.27-vanilla.patch
lustre/kernel_patches/patches/dev_read_only-2.6.32-rhel6.patch
lustre/lvfs/lvfs_linux.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/obdfilter/filter.c
lustre/osd-ldiskfs/osd_handler.c

index 3181183..061d457 100644 (file)
@@ -104,24 +104,15 @@ AC_DEFUN([LC_LUSTRE_VERSION_H],
 #
 # LC_FUNC_DEV_SET_RDONLY
 #
 #
 # LC_FUNC_DEV_SET_RDONLY
 #
-# check for the old-style dev_set_rdonly which took an extra "devno" param
-# and can only set a single device to discard writes at one time
+# check whether dev_set_rdonly is exported.  This is needed until we
+# have another mechanism to fence IO from the underlying device.
 #
 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
 #
 AC_DEFUN([LC_FUNC_DEV_SET_RDONLY],
-[AC_MSG_CHECKING([if kernel has new dev_set_rdonly])
-LB_LINUX_TRY_COMPILE([
-        #include <linux/fs.h>
-        #include <linux/blkdev.h>
-],[
-        #ifndef HAVE_CLEAR_RDONLY_ON_PUT
-        #error needs to be patched by lustre kernel patches from Lustre version 1.4.3 or above.
-        #endif
-],[
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel has new dev_set_rdonly])
+[LB_CHECK_SYMBOL_EXPORT([dev_set_rdonly],
+[block/ll_rw_block.c,block/blk-core.c],[
+        AC_DEFINE(HAVE_DEV_SET_RDONLY, 1, [kernel exports dev_set_rdonly])
 ],[
 ],[
-        AC_MSG_ERROR([no, Linux kernel source needs to be patches by lustre
-kernel patches from Lustre version 1.4.3 or above.])
+        AC_MSG_WARN([kernel missing dev_set_rdonly patch for testing])
 ])
 ])
 
 ])
 ])
 
index edee55a..9abb6d9 100644 (file)
@@ -153,7 +153,7 @@ struct dt_device_operations {
          *  handling device state, mostly for tests
          */
         int   (*dt_sync)(const struct lu_env *env, struct dt_device *dev);
          *  handling device state, mostly for tests
          */
         int   (*dt_sync)(const struct lu_env *env, struct dt_device *dev);
-        void  (*dt_ro)(const struct lu_env *env, struct dt_device *dev);
+        int   (*dt_ro)(const struct lu_env *env, struct dt_device *dev);
         /**
           * Start a transaction commit asynchronously
           *
         /**
           * Start a transaction commit asynchronously
           *
@@ -1097,7 +1097,7 @@ static inline int dt_sync(const struct lu_env *env, struct dt_device *dev)
         return dev->dd_ops->dt_sync(env, dev);
 }
 
         return dev->dd_ops->dt_sync(env, dev);
 }
 
-static inline void dt_ro(const struct lu_env *env, struct dt_device *dev)
+static inline int dt_ro(const struct lu_env *env, struct dt_device *dev)
 {
         LASSERT(dev);
         LASSERT(dev->dd_ops);
 {
         LASSERT(dev);
         LASSERT(dev->dd_ops);
index e38ee13..2cbb755 100644 (file)
@@ -87,7 +87,7 @@ int fsync_bdev(struct block_device *);
 #define lvfs_set_rdonly(obd, sb) \
         __lvfs_set_rdonly(lvfs_sbdev(sb), fsfilt_journal_sbdev(obd, sb))
 
 #define lvfs_set_rdonly(obd, sb) \
         __lvfs_set_rdonly(lvfs_sbdev(sb), fsfilt_journal_sbdev(obd, sb))
 
-void __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev);
+int __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev);
 
 int lvfs_check_rdonly(lvfs_sbdev_type dev);
 void lvfs_clear_rdonly(lvfs_sbdev_type dev);
 
 int lvfs_check_rdonly(lvfs_sbdev_type dev);
 void lvfs_clear_rdonly(lvfs_sbdev_type dev);
index db9e46f..4c96565 100644 (file)
@@ -445,23 +445,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
 #define OBD_FAIL_ONCE                           CFS_FAIL_ONCE
 #define OBD_FAILED                              CFS_FAILED
 
 #define OBD_FAIL_ONCE                           CFS_FAIL_ONCE
 #define OBD_FAILED                              CFS_FAILED
 
-#ifdef __KERNEL__
-static inline void obd_fail_write(int id, struct super_block *sb)
-{
-        /* We set FAIL_ONCE because we never "un-fail" a device */
-        if (OBD_FAIL_CHECK_ORSET(id & ~OBD_FAIL_ONCE, OBD_FAIL_ONCE)) {
-#ifdef LIBCFS_DEBUG
-                BDEVNAME_DECLARE_STORAGE(tmp);
-                CERROR("cfs_fail_loc=%x, fail write operation on %s\n",
-                       id, ll_bdevname(sb, tmp));
-#endif
-                /* TODO-CMD: fix getting jdev */
-                __lvfs_set_rdonly(lvfs_sbdev(sb), (lvfs_sbdev_type)0);
-        }
-}
-#define OBD_FAIL_WRITE(id, sb) obd_fail_write(id, sb)
-#endif
-
 extern cfs_atomic_t libcfs_kmemory;
 
 #ifdef LPROCFS
 extern cfs_atomic_t libcfs_kmemory;
 
 #ifdef LPROCFS
index 39c3b62..a12fb3f 100644 (file)
@@ -1,3 +1,24 @@
+This patch is no longer needed for Lustre.  It is only included
+for testing and ease of using the same kernel with older Lustre
+versions.  This testing functionality was replaced in Linux 3.0
+by the dm-flakey driver.
+
+This functionality is mainly used during testing, in order to
+simulate a server crash for ldiskfs by discarding all of the
+writes to the filesystem.  For recovery testing we could simulate
+this by using a special loopback or DM device that also discards
+writes to the device.
+
+This functionality is also used by target "failback" in order
+to speed up service shutdown and takeover by the other node
+during controlled operation.  However, it would also be possible
+to do this by simply allowing all of the in-flight requests to
+complete and then waiting for the service to stop.  This will
+also be needed by the DMU-OSD, because discarding of writes on
+a DMU-based target is not safe as it could trigger a storage
+failure if the data is ever read from disk again and the
+checksum does not match that expected by the block pointer.
+
 Index: linux-2.6.18.1/block/ll_rw_blk.c
 ===================================================================
 --- linux-2.6.18.1.orig/block/ll_rw_blk.c
 Index: linux-2.6.18.1/block/ll_rw_blk.c
 ===================================================================
 --- linux-2.6.18.1.orig/block/ll_rw_blk.c
index de7804d..8e465e2 100644 (file)
@@ -1,3 +1,24 @@
+This patch is no longer needed for Lustre.  It is only included
+for testing and ease of using the same kernel with older Lustre
+versions.  This testing functionality was replaced in Linux 3.0
+by the dm-flakey driver.
+
+This functionality is mainly used during testing, in order to
+simulate a server crash for ldiskfs by discarding all of the
+writes to the filesystem.  For recovery testing we could simulate
+this by using a special loopback or DM device that also discards
+writes to the device.
+
+This functionality is also used by target "failback" in order
+to speed up service shutdown and takeover by the other node
+during controlled operation.  However, it would also be possible
+to do this by simply allowing all of the in-flight requests to
+complete and then waiting for the service to stop.  This will
+also be needed by the DMU-OSD, because discarding of writes on
+a DMU-based target is not safe as it could trigger a storage
+failure if the data is ever read from disk again and the
+checksum does not match that expected by the block pointer.
+
 Index: linux-2.6.27.21-0.1/block/blk-core.c
 ===================================================================
 --- linux-2.6.27.21-0.1.orig/block/blk-core.c  2009-04-23 02:12:51.000000000 -0600
 Index: linux-2.6.27.21-0.1/block/blk-core.c
 ===================================================================
 --- linux-2.6.27.21-0.1.orig/block/blk-core.c  2009-04-23 02:12:51.000000000 -0600
index 38aecf3..54b51cb 100644 (file)
@@ -1,3 +1,8 @@
+This patch is no longer needed for Lustre.  It is only included
+for testing and ease of using the same kernel with older Lustre
+versions.  This testing functionality was replaced in Linux 3.0
+by the dm-flakey driver.
+
 This functionality is mainly used during testing, in order to
 simulate a server crash for ldiskfs by discarding all of the
 writes to the filesystem.  For recovery testing we could simulate
 This functionality is mainly used during testing, in order to
 simulate a server crash for ldiskfs by discarding all of the
 writes to the filesystem.  For recovery testing we could simulate
@@ -14,9 +19,6 @@ a DMU-based target is not safe as it could trigger a storage
 failure if the data is ever read from disk again and the
 checksum does not match that expected by the block pointer.
 
 failure if the data is ever read from disk again and the
 checksum does not match that expected by the block pointer.
 
-Initial efforts to remove this patch are under way in bug 20776.
-Once this work comes to fruition this patch can be dropped.
-
 Index: linux-2.6.32-131.0.15.el6.x86_64/block/blk-core.c
 ===================================================================
 --- linux-2.6.32-131.0.15.el6.x86_64.orig/block/blk-core.c     2011-05-10 21:38:33.000000000 +0300
 Index: linux-2.6.32-131.0.15.el6.x86_64/block/blk-core.c
 ===================================================================
 --- linux-2.6.32-131.0.15.el6.x86_64.orig/block/blk-core.c     2011-05-10 21:38:33.000000000 +0300
index 30a6c91..63d2992 100644 (file)
@@ -489,14 +489,9 @@ out:
 EXPORT_SYMBOL(simple_truncate);
 
 #ifdef LUSTRE_KERNEL_VERSION
 EXPORT_SYMBOL(simple_truncate);
 
 #ifdef LUSTRE_KERNEL_VERSION
-#ifndef HAVE_CLEAR_RDONLY_ON_PUT
-#error rdonly patchset must be updated [cfs bz11248]
-#endif
-void dev_set_rdonly(lvfs_sbdev_type dev);
-int dev_check_rdonly(lvfs_sbdev_type dev);
-
-void __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev)
+int __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev)
 {
 {
+#ifdef HAVE_DEV_SET_RDONLY
         if (jdev && (jdev != dev)) {
                 CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
                        (long)jdev);
         if (jdev && (jdev != dev)) {
                 CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
                        (long)jdev);
@@ -504,14 +499,24 @@ void __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev)
         }
         CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
         dev_set_rdonly(dev);
         }
         CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
         dev_set_rdonly(dev);
+
+        return 0;
+#else
+        CERROR("DEV %lx CANNOT BE SET READONLY\n", (long)dev);
+
+        return -EOPNOTSUPP;
+#endif
 }
 }
+EXPORT_SYMBOL(__lvfs_set_rdonly);
 
 int lvfs_check_rdonly(lvfs_sbdev_type dev)
 {
 
 int lvfs_check_rdonly(lvfs_sbdev_type dev)
 {
+#ifdef HAVE_DEV_SET_RDONLY
         return dev_check_rdonly(dev);
         return dev_check_rdonly(dev);
+#else
+        return 0;
+#endif
 }
 }
-
-EXPORT_SYMBOL(__lvfs_set_rdonly);
 EXPORT_SYMBOL(lvfs_check_rdonly);
 
 int lvfs_check_io_health(struct obd_device *obd, struct file *file)
 EXPORT_SYMBOL(lvfs_check_rdonly);
 
 int lvfs_check_io_health(struct obd_device *obd, struct file *file)
index 1db26a7..55ab803 100644 (file)
@@ -5554,7 +5554,7 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 rc = mdt_device_sync(&env, mdt);
                 break;
         case OBD_IOC_SET_READONLY:
                 rc = mdt_device_sync(&env, mdt);
                 break;
         case OBD_IOC_SET_READONLY:
-                dt->dd_ops->dt_ro(&env, dt);
+                rc = dt->dd_ops->dt_ro(&env, dt);
                 break;
         case OBD_IOC_ABORT_RECOVERY:
                 CERROR("Aborting recovery for device %s\n", obd->obd_name);
                 break;
         case OBD_IOC_ABORT_RECOVERY:
                 CERROR("Aborting recovery for device %s\n", obd->obd_name);
index 2050560..8913d67 100644 (file)
@@ -683,15 +683,17 @@ int mdt_pack_remote_perm(struct mdt_thread_info *, struct mdt_object *, void *);
 
 extern struct lu_context_key       mdt_thread_key;
 /* debug issues helper starts here*/
 
 extern struct lu_context_key       mdt_thread_key;
 /* debug issues helper starts here*/
-static inline void mdt_fail_write(const struct lu_env *env,
-                                  struct dt_device *dd, int id)
+static inline int mdt_fail_write(const struct lu_env *env,
+                                 struct dt_device *dd, int id)
 {
         if (OBD_FAIL_CHECK_ORSET(id, OBD_FAIL_ONCE)) {
                 CERROR(LUSTRE_MDT_NAME": cfs_fail_loc=%x, fail write ops\n",
                        id);
 {
         if (OBD_FAIL_CHECK_ORSET(id, OBD_FAIL_ONCE)) {
                 CERROR(LUSTRE_MDT_NAME": cfs_fail_loc=%x, fail write ops\n",
                        id);
-                dd->dd_ops->dt_ro(env, dd);
+                return dd->dd_ops->dt_ro(env, dd);
                 /* We set FAIL_ONCE because we never "un-fail" a device */
         }
                 /* We set FAIL_ONCE because we never "un-fail" a device */
         }
+
+        return 0;
 }
 
 static inline struct mdt_export_data *mdt_req2med(struct ptlrpc_request *req)
 }
 
 static inline struct mdt_export_data *mdt_req2med(struct ptlrpc_request *req)
index 17ace2e..984defe 100644 (file)
@@ -4642,8 +4642,8 @@ int filter_iocontrol(unsigned int cmd, struct obd_export *exp,
                 CDEBUG(D_HA, "syncing ost %s\n", obd->obd_name);
                 rc = fsfilt_sync(obd, obd->u.obt.obt_sb);
 
                 CDEBUG(D_HA, "syncing ost %s\n", obd->obd_name);
                 rc = fsfilt_sync(obd, obd->u.obt.obt_sb);
 
-                lvfs_set_rdonly(obd, obd->u.obt.obt_sb);
-                RETURN(0);
+                rc = lvfs_set_rdonly(obd, obd->u.obt.obt_sb);
+                RETURN(rc);
         }
 
         case OBD_IOC_CATLOGLIST: {
         }
 
         case OBD_IOC_CATLOGLIST: {
index 84e7573..e1dfcec 100644 (file)
@@ -924,15 +924,16 @@ static int osd_commit_async(const struct lu_env *env,
  * Concurrency: shouldn't matter.
  */
 
  * Concurrency: shouldn't matter.
  */
 
-static void osd_ro(const struct lu_env *env, struct dt_device *d)
+static int osd_ro(const struct lu_env *env, struct dt_device *d)
 {
         struct super_block *sb = osd_sb(osd_dt_dev(d));
 {
         struct super_block *sb = osd_sb(osd_dt_dev(d));
+        int rc;
         ENTRY;
 
         CERROR("*** setting device %s read-only ***\n", LUSTRE_OSD_NAME);
 
         ENTRY;
 
         CERROR("*** setting device %s read-only ***\n", LUSTRE_OSD_NAME);
 
-        __lvfs_set_rdonly(sb->s_bdev, LDISKFS_SB(sb)->journal_bdev);
-        EXIT;
+        rc = __lvfs_set_rdonly(sb->s_bdev, LDISKFS_SB(sb)->journal_bdev);
+        RETURN(rc);
 }
 
 /*
 }
 
 /*