[PATCH] Remove DIO_OWN_LOCKING

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
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: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux