From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert S Peterson Subject: [patch 2.6.16] loop.c to use write ops for fs requiring special locking [try #2] Date: Fri, 24 Mar 2006 11:07:31 -0600 Message-ID: <1143220052.12806.27.camel@technetium.msp.redhat.com> References: <1141231737.15117.88.camel@technetium.msp.redhat.com> <20060301140902.53350bb6.akpm@osdl.org> <1142031897.27533.40.camel@technetium.msp.redhat.com> <20060310151353.584ddfd5.akpm@osdl.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Andrew Morton , linux-fsdevel@vger.kernel.org Return-path: Received: from mx1.redhat.com ([66.187.233.31]:34970 "EHLO mx1.redhat.com") by vger.kernel.org with ESMTP id S1751158AbWCXRFG (ORCPT ); Fri, 24 Mar 2006 12:05:06 -0500 To: Anton Altaparmakov In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sat, 2006-03-11 at 00:36 +0000, Anton Altaparmakov wrote: > On Fri, 10 Mar 2006, Andrew Morton wrote: > > When we've remembered what Al's statement meant in > > http://marc.theaimsgroup.com/?t=102129995600002&r=1&w=2 > This is no longer relevant because my patch which is in current 2.6 > kernels (can't remember when I wrote it/when it got put into 2.6) did the > conversion from prepare_write/commit_write to file ->write correctly so > the data transformation still happens so that crypto still works with the > loop driver. > > To get back to Robert's patch that he is requesting to be included. I > think it is fine but the flag name could perhaps be better. Perhaps > "FS_AOPS_PRIVATE" or "FS_AOPS_SPECIAL" or "FS_AOPS_NEED_LOCKING" or > even "FS_AOPS_REQUIRE_LOCKING" or something. "FS_REQUIRES_LOCKING" just > does not mean much and certainly would not suggest to me that no-one > outside the file system should use the address space operations of the > file system... But maybe I am just bein picky. (-: Here is a resubmission of my patch to loop.c, this time against the 2.6.16 kernel. Andrew: Sounds like Anton answered your concerns. Anton: As per your suggestion, I changed the constant to your suggested FS_AOPS_NEED_LOCKING. Regards, Bob Peterson rpeterso@redhat.com diff -pur linux-2.6.16/drivers/block/loop.c linux-2.6.16.patched/drivers/block/loop.c --- linux-2.6.16/drivers/block/loop.c 2006-03-19 23:53:29.000000000 -0600 +++ linux-2.6.16.patched/drivers/block/loop.c 2006-03-24 10:49:10.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 , 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 #include #include +#include #include @@ -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 -pur linux-2.6.16/include/linux/fs.h linux-2.6.16.patched/include/linux/fs.h --- linux-2.6.16/include/linux/fs.h 2006-03-19 23:53:29.000000000 -0600 +++ linux-2.6.16.patched/include/linux/fs.h 2006-03-24 10:27:20.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_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