#
# 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_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])
])
])
* 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
*
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);
#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);
#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
+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
+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
+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
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
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);
}
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)
{
+#ifdef HAVE_DEV_SET_RDONLY
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)
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);
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);
- 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 */
}
+
+ return 0;
}
static inline struct mdt_export_data *mdt_req2med(struct ptlrpc_request *req)
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: {
* 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));
+ int rc;
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);
}
/*