From: Russell Cattelan <cattelan@thebarn.com>
To: linux-fsdevel@vger.kernel.org
Cc: xfs@oss.sgi.com
Subject: [PATCH] Remove DIO_OWN_LOCKING
Date: Thu, 12 Oct 2006 19:56:38 -0500 [thread overview]
Message-ID: <1160700998.5723.65.camel@xenon.msp.redhat.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 501 bytes --]
While trying to fix up GFS2 directio and reading through the code
involving the various lock flags I discovered the DIO_OWN_LOCKING
flag is no longer used.
XFS recently changed it xfs_vm_direct_IO function to call
blockdev_direct_IO_no_locking for reads and
blockdev_direct_IO_own_locking
for writes. But DIO_OWN_LOCKING is only used in the direct IO read case
so effectively the flag is never checked an therefore can probably be
removed.
--
Russell Cattelan <cattelan@thebarn.com>
[-- Attachment #1.2: wack_own_locking --]
[-- Type: text/x-patch, Size: 5493 bytes --]
Index: work_gfs/fs/direct-io.c
===================================================================
--- work_gfs.orig/fs/direct-io.c 2006-10-12 18:01:09.000000000 -0500
+++ work_gfs/fs/direct-io.c 2006-10-12 19:49:26.348843927 -0500
@@ -67,9 +67,7 @@ int dio_debug = 0x0;
* lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems.
* This determines whether we need to do the fancy locking which prevents
* direct-IO from being able to read uninitialised disk blocks. If its zero
- * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_mutex is
- * not held for the entire direct write (taken briefly, initially, during a
- * direct read though, but its never held for the duration of a direct-IO).
+ * (blockdev) this locking is not done.
*/
struct dio {
@@ -1179,12 +1177,6 @@ direct_io_worker(int rw, struct kiocb *i
* For reads, i_mutex is not held on entry, but it is taken and dropped before
* returning.
*
- * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of
- * uninitialised data, allowing parallel direct readers and writers)
- * For writes we are called without i_mutex, return without it, never touch it.
- * For reads we are called under i_mutex and return with i_mutex held, even
- * though it may be internally dropped.
- *
* Additional i_alloc_sem locking requirements described inline below.
*/
ssize_t
@@ -1202,8 +1194,6 @@ __blockdev_direct_IO(int rw, struct kioc
ssize_t retval = -EINVAL;
loff_t end = offset;
struct dio *dio;
- int release_i_mutex = 0;
- int acquire_i_mutex = 0;
if (rw & WRITE)
rw = WRITE_SYNC;
@@ -1244,32 +1234,24 @@ __blockdev_direct_IO(int rw, struct kioc
* For regular files using DIO_LOCKING,
* readers need to grab i_mutex and i_alloc_sem
* writers need to grab i_alloc_sem only (i_mutex is already held)
- * For regular files using DIO_OWN_LOCKING,
- * neither readers nor writers take any locks here
*/
dio->lock_type = dio_lock_type;
if (dio_lock_type != DIO_NO_LOCKING) {
/* watch out for a 0 len io from a tricksy fs */
if (rw == READ && end > offset) {
struct address_space *mapping;
-
mapping = iocb->ki_filp->f_mapping;
- if (dio_lock_type != DIO_OWN_LOCKING) {
- mutex_lock(&inode->i_mutex);
- release_i_mutex = 1;
- }
+
+ mutex_lock(&inode->i_mutex);
retval = filemap_write_and_wait_range(mapping, offset,
end - 1);
if (retval) {
+ mutex_unlock(&inode->i_mutex);
kfree(dio);
goto out;
}
- if (dio_lock_type == DIO_OWN_LOCKING) {
- mutex_unlock(&inode->i_mutex);
- acquire_i_mutex = 1;
- }
}
if (dio_lock_type == DIO_LOCKING)
@@ -1289,14 +1271,7 @@ __blockdev_direct_IO(int rw, struct kioc
retval = direct_io_worker(rw, iocb, inode, iov, offset,
nr_segs, blkbits, get_block, end_io, dio);
- if (rw == READ && dio_lock_type == DIO_LOCKING)
- release_i_mutex = 0;
-
out:
- if (release_i_mutex)
- mutex_unlock(&inode->i_mutex);
- else if (acquire_i_mutex)
- mutex_lock(&inode->i_mutex);
return retval;
}
EXPORT_SYMBOL(__blockdev_direct_IO);
Index: work_gfs/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- work_gfs.orig/fs/xfs/linux-2.6/xfs_aops.c 2006-10-02 12:31:01.000000000 -0500
+++ work_gfs/fs/xfs/linux-2.6/xfs_aops.c 2006-10-12 19:10:51.068066857 -0500
@@ -1389,19 +1389,11 @@ xfs_vm_direct_IO(
iocb->private = xfs_alloc_ioend(inode, IOMAP_UNWRITTEN);
- if (rw == WRITE) {
- ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
- iomap.iomap_target->bt_bdev,
- iov, offset, nr_segs,
- xfs_get_blocks_direct,
- xfs_end_io_direct);
- } else {
- ret = blockdev_direct_IO_no_locking(rw, iocb, inode,
- iomap.iomap_target->bt_bdev,
- iov, offset, nr_segs,
- xfs_get_blocks_direct,
- xfs_end_io_direct);
- }
+ ret = blockdev_direct_IO_no_locking(rw, iocb, inode,
+ iomap.iomap_target->bt_bdev,
+ iov, offset, nr_segs,
+ xfs_get_blocks_direct,
+ xfs_end_io_direct);
if (unlikely(ret <= 0 && iocb->private))
xfs_destroy_ioend(iocb->private);
Index: work_gfs/include/linux/fs.h
===================================================================
--- work_gfs.orig/include/linux/fs.h 2006-10-06 15:42:44.000000000 -0500
+++ work_gfs/include/linux/fs.h 2006-10-12 19:48:31.416160412 -0500
@@ -1723,7 +1723,6 @@ ssize_t __blockdev_direct_IO(int rw, str
enum {
DIO_LOCKING = 1, /* need locking between buffered and direct access */
DIO_NO_LOCKING, /* bdev; no locking at all between buffered/direct */
- DIO_OWN_LOCKING, /* filesystem locks buffered and direct internally */
};
static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
@@ -1744,15 +1743,6 @@ static inline ssize_t blockdev_direct_IO
nr_segs, get_block, end_io, DIO_NO_LOCKING);
}
-static inline ssize_t blockdev_direct_IO_own_locking(int rw, struct kiocb *iocb,
- struct inode *inode, struct block_device *bdev, const struct iovec *iov,
- loff_t offset, unsigned long nr_segs, get_block_t get_block,
- dio_iodone_t end_io)
-{
- return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
- nr_segs, get_block, end_io, DIO_OWN_LOCKING);
-}
-
extern const struct file_operations generic_ro_fops;
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2006-10-13 0:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-13 0:56 Russell Cattelan [this message]
2006-10-13 2:48 ` [PATCH] Remove DIO_OWN_LOCKING David Chinner
2006-10-13 18:09 ` Russell Cattelan
2006-10-15 21:57 ` David Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1160700998.5723.65.camel@xenon.msp.redhat.com \
--to=cattelan@thebarn.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).