aboutsummaryrefslogtreecommitdiffstats
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-01-09 18:59:24 -0500
committerIngo Molnar <mingo@hera.kernel.org>2006-01-09 18:59:24 -0500
commit1b1dcc1b57a49136f118a0f16367256ff9994a69 (patch)
treeb0b36d4f41d28c9d6514fb309d33c1a084d6309b /fs/direct-io.c
parent794ee1baee1c26be40410233e6c20bceb2b03c08 (diff)
[PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem
This patch converts the inode semaphore to a mutex. I have tested it on XFS and compiled as much as one can consider on an ia64. Anyway your luck with it might be different. Modified-by: Ingo Molnar <mingo@elte.hu> (finished the conversion) Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 3931e7f1e6bf..30dbbd1df511 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -56,7 +56,7 @@
56 * lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems. 56 * lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems.
57 * This determines whether we need to do the fancy locking which prevents 57 * This determines whether we need to do the fancy locking which prevents
58 * direct-IO from being able to read uninitialised disk blocks. If its zero 58 * direct-IO from being able to read uninitialised disk blocks. If its zero
59 * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_sem is 59 * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_mutex is
60 * not held for the entire direct write (taken briefly, initially, during a 60 * not held for the entire direct write (taken briefly, initially, during a
61 * direct read though, but its never held for the duration of a direct-IO). 61 * direct read though, but its never held for the duration of a direct-IO).
62 */ 62 */
@@ -930,7 +930,7 @@ out:
930} 930}
931 931
932/* 932/*
933 * Releases both i_sem and i_alloc_sem 933 * Releases both i_mutex and i_alloc_sem
934 */ 934 */
935static ssize_t 935static ssize_t
936direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, 936direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
@@ -1062,11 +1062,11 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
1062 1062
1063 /* 1063 /*
1064 * All block lookups have been performed. For READ requests 1064 * All block lookups have been performed. For READ requests
1065 * we can let i_sem go now that its achieved its purpose 1065 * we can let i_mutex go now that its achieved its purpose
1066 * of protecting us from looking up uninitialized blocks. 1066 * of protecting us from looking up uninitialized blocks.
1067 */ 1067 */
1068 if ((rw == READ) && (dio->lock_type == DIO_LOCKING)) 1068 if ((rw == READ) && (dio->lock_type == DIO_LOCKING))
1069 up(&dio->inode->i_sem); 1069 mutex_unlock(&dio->inode->i_mutex);
1070 1070
1071 /* 1071 /*
1072 * OK, all BIOs are submitted, so we can decrement bio_count to truly 1072 * OK, all BIOs are submitted, so we can decrement bio_count to truly
@@ -1145,18 +1145,18 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
1145 * The locking rules are governed by the dio_lock_type parameter. 1145 * The locking rules are governed by the dio_lock_type parameter.
1146 * 1146 *
1147 * DIO_NO_LOCKING (no locking, for raw block device access) 1147 * DIO_NO_LOCKING (no locking, for raw block device access)
1148 * For writes, i_sem is not held on entry; it is never taken. 1148 * For writes, i_mutex is not held on entry; it is never taken.
1149 * 1149 *
1150 * DIO_LOCKING (simple locking for regular files) 1150 * DIO_LOCKING (simple locking for regular files)
1151 * For writes we are called under i_sem and return with i_sem held, even though 1151 * For writes we are called under i_mutex and return with i_mutex held, even though
1152 * it is internally dropped. 1152 * it is internally dropped.
1153 * For reads, i_sem is not held on entry, but it is taken and dropped before 1153 * For reads, i_mutex is not held on entry, but it is taken and dropped before
1154 * returning. 1154 * returning.
1155 * 1155 *
1156 * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of 1156 * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of
1157 * uninitialised data, allowing parallel direct readers and writers) 1157 * uninitialised data, allowing parallel direct readers and writers)
1158 * For writes we are called without i_sem, return without it, never touch it. 1158 * For writes we are called without i_mutex, return without it, never touch it.
1159 * For reads, i_sem is held on entry and will be released before returning. 1159 * For reads, i_mutex is held on entry and will be released before returning.
1160 * 1160 *
1161 * Additional i_alloc_sem locking requirements described inline below. 1161 * Additional i_alloc_sem locking requirements described inline below.
1162 */ 1162 */
@@ -1214,11 +1214,11 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1214 * For block device access DIO_NO_LOCKING is used, 1214 * For block device access DIO_NO_LOCKING is used,
1215 * neither readers nor writers do any locking at all 1215 * neither readers nor writers do any locking at all
1216 * For regular files using DIO_LOCKING, 1216 * For regular files using DIO_LOCKING,
1217 * readers need to grab i_sem and i_alloc_sem 1217 * readers need to grab i_mutex and i_alloc_sem
1218 * writers need to grab i_alloc_sem only (i_sem is already held) 1218 * writers need to grab i_alloc_sem only (i_mutex is already held)
1219 * For regular files using DIO_OWN_LOCKING, 1219 * For regular files using DIO_OWN_LOCKING,
1220 * neither readers nor writers take any locks here 1220 * neither readers nor writers take any locks here
1221 * (i_sem is already held and release for writers here) 1221 * (i_mutex is already held and release for writers here)
1222 */ 1222 */
1223 dio->lock_type = dio_lock_type; 1223 dio->lock_type = dio_lock_type;
1224 if (dio_lock_type != DIO_NO_LOCKING) { 1224 if (dio_lock_type != DIO_NO_LOCKING) {
@@ -1228,7 +1228,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1228 1228
1229 mapping = iocb->ki_filp->f_mapping; 1229 mapping = iocb->ki_filp->f_mapping;
1230 if (dio_lock_type != DIO_OWN_LOCKING) { 1230 if (dio_lock_type != DIO_OWN_LOCKING) {
1231 down(&inode->i_sem); 1231 mutex_lock(&inode->i_mutex);
1232 reader_with_isem = 1; 1232 reader_with_isem = 1;
1233 } 1233 }
1234 1234
@@ -1240,7 +1240,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1240 } 1240 }
1241 1241
1242 if (dio_lock_type == DIO_OWN_LOCKING) { 1242 if (dio_lock_type == DIO_OWN_LOCKING) {
1243 up(&inode->i_sem); 1243 mutex_unlock(&inode->i_mutex);
1244 reader_with_isem = 0; 1244 reader_with_isem = 0;
1245 } 1245 }
1246 } 1246 }
@@ -1266,7 +1266,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1266 1266
1267out: 1267out:
1268 if (reader_with_isem) 1268 if (reader_with_isem)
1269 up(&inode->i_sem); 1269 mutex_unlock(&inode->i_mutex);
1270 if (rw & WRITE) 1270 if (rw & WRITE)
1271 current->flags &= ~PF_SYNCWRITE; 1271 current->flags &= ~PF_SYNCWRITE;
1272 return retval; 1272 return retval;