linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] loop.c to use write ops for fs requiring special locking
@ 2006-03-27 21:52 Robert S Peterson
  2006-03-28  0:44 ` Andrew Morton
  2006-03-28 14:40 ` Christoph Hellwig
  0 siblings, 2 replies; 15+ messages in thread
From: Robert S Peterson @ 2006-03-27 21:52 UTC (permalink / raw)
  To: Anton Altaparmakov, Andrew Morton, fs-devel mailing list

Use normal write file operations rather than AOPS prepare_write and
commit_write when the backing filesystem requires special locking.

Signed-off-by:  Robert Peterson <rpeterso@redhat.com>

---

 drivers/block/loop.c |    9 ++++++++-
 include/linux/fs.h   |    1 +
 2 files changed, 9 insertions(+), 1 deletions(-)

121d2e76ae4b3f7ca3741e410664e138db5e1b13
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 9c3b94e..c762e76 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -44,6 +44,11 @@
  * backing filesystem.
  * Anton Altaparmakov, 16 Feb 2005
  *
+ * Extension of Anton's idea: Use normal write file operations rather than
+ * prepare_write and commit_write when the backing filesystem requires
+ * special locking.
+ * Robert Peterson <rpeterso@redhat.com>, 01 Mar 2006
+ *
  * Still To Fix:
  * - Advisory locking is ignored here.
  * - Should use an own CAP_* category instead of CAP_SYS_ADMIN
@@ -74,6 +79,7 @@
 #include <linux/completion.h>
 #include <linux/highmem.h>
 #include <linux/gfp.h>
+#include <linux/mount.h>

 #include <asm/uaccess.h>

@@ -791,7 +797,8 @@ static int loop_set_fd(struct loop_devic
                 */
                if (!file->f_op->sendfile)
                        goto out_putf;
-               if (aops->prepare_write && aops->commit_write)
+               if (!(file->f_vfsmnt->mnt_sb->s_type->fs_flags & FS_AOPS_NEED_LOCKING) &&
+                       aops->prepare_write && aops->commit_write)
                        lo_flags |= LO_FLAGS_USE_AOPS;
                if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write)
                        lo_flags |= LO_FLAGS_READ_ONLY;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9d96749..3def72e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -88,6 +88,7 @@ extern int dir_notify_enable;
 /* public flags for file_system_type */
 #define FS_REQUIRES_DEV 1
 #define FS_BINARY_MOUNTDATA 2
+#define FS_AOPS_NEED_LOCKING 4 /* Filesystem aops have special locking needs */
 #define FS_REVAL_DOT   16384   /* Check the paths ".", ".." for staleness */
 #define FS_ODD_RENAME  32768   /* Temporary stuff; will go away as soon
                                  * as nfs_rename() will be cleaned up
--
1.2.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [patch] loop.c to use write ops for fs requiring special locking
@ 2006-03-01 16:48 Robert S Peterson
  2006-03-01 22:09 ` Andrew Morton
  0 siblings, 1 reply; 15+ messages in thread
From: Robert S Peterson @ 2006-03-01 16:48 UTC (permalink / raw)
  To: fs-devel mailing list, Andrew Morton, Anton Altaparmakov

Hi All,

Below is a small patch to loop.c I'd like to see in the kernel.

This is an extension of Anton Altaparmakov's previous fix which allows
loop.c to use the aop->write rather than prepare_write/commit_write if
prepare_write/commit_write aren't available.

Right now, the current loop.c uses aop->prepare_write/commit_write
unless there is no other option.  However, due to special locking
requirements, some backing filesystems may prefer the use of aop->write
rather than prepare_write/commit_write.  Since loop.c does not have
advisory locking, the backing fs should have a choice of which to use.

In the case of GFS, for example, loop.c's use of aop->prepare_write
circumvents proper cluster locking and transaction building, so using
aop->write is the right thing for loop.c to do.

How the patch works:
If the backing filesystem has special locking requirements (new flag in
fs_flags) loop.c uses aop->write rather than prepare_write/commit_write.

Feedback?

Regards,

Bob Peterson
rpeterso@redhat.com

--- linux-2.6.15.4.orig/drivers/block/loop.c    2006-02-10
01:22:48.000000000 -0600
+++ linux-2.6.15.4.patched/drivers/block/loop.c 2006-03-01
09:38:48.000000000 -0600
@@ -44,6 +44,11 @@
  * backing filesystem.
  * Anton Altaparmakov, 16 Feb 2005
  *
+ * Extension of Anton's idea: Use normal write file operations rather
+ * than prepare_write and commit_write when the backing filesystem
+ * requires special locking.
+ * Robert Peterson <rpeterso@redhat.com>, 01 Mar 2006
+ *
  * Still To Fix:
  * - Advisory locking is ignored here.
  * - Should use an own CAP_* category instead of CAP_SYS_ADMIN
@@ -74,6 +79,7 @@
 #include <linux/completion.h>
 #include <linux/highmem.h>
 #include <linux/gfp.h>
+#include <linux/mount.h>

 #include <asm/uaccess.h>

@@ -781,7 +787,8 @@ static int loop_set_fd(struct loop_devic
                 */
                if (!file->f_op->sendfile)
                        goto out_putf;
-               if (aops->prepare_write && aops->commit_write)
+               if (!(file->f_vfsmnt->mnt_sb->s_type->fs_flags &
FS_REQUIRES_LOCKING) &&
+                       aops->prepare_write && aops->commit_write)
                        lo_flags |= LO_FLAGS_USE_AOPS;
                if (!(lo_flags & LO_FLAGS_USE_AOPS) && !
file->f_op->write)
                        lo_flags |= LO_FLAGS_READ_ONLY;
diff -pur linux-2.6.15.4.orig/include/linux/fs.h
linux-2.6.15.4.patched/include/linux/fs.h
--- linux-2.6.15.4.orig/include/linux/fs.h      2006-02-10
01:22:48.000000000 -0600
+++ linux-2.6.15.4.patched/include/linux/fs.h   2006-02-28
17:18:48.000000000 -0600
@@ -83,6 +83,7 @@ extern int dir_notify_enable;
 /* public flags for file_system_type */
 #define FS_REQUIRES_DEV 1
 #define FS_BINARY_MOUNTDATA 2
+#define FS_REQUIRES_LOCKING 4   /* Filesystem requires locking */
 #define FS_REVAL_DOT   16384   /* Check the paths ".", ".." for
staleness */
 #define FS_ODD_RENAME  32768   /* Temporary stuff; will go away as soon
                                  * as nfs_rename() will be cleaned up



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-03-30 14:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-27 21:52 [PATCH] loop.c to use write ops for fs requiring special locking Robert S Peterson
2006-03-28  0:44 ` Andrew Morton
2006-03-28 15:33   ` Robert S Peterson
2006-03-28 19:27     ` Andrew Morton
2006-03-28 14:40 ` Christoph Hellwig
2006-03-28 15:59   ` Robert S Peterson
2006-03-29  9:05     ` Christoph Hellwig
2006-03-30  0:10       ` Robert S Peterson
2006-03-30 14:15         ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2006-03-01 16:48 [patch] " Robert S Peterson
2006-03-01 22:09 ` Andrew Morton
2006-03-02 10:16   ` Anton Altaparmakov
2006-03-10 23:04     ` Robert S Peterson
2006-03-10 23:13       ` Andrew Morton
2006-03-11  0:36         ` Anton Altaparmakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).