aboutsummaryrefslogtreecommitdiffstats
path: root/fs/attr.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-06-24 14:29:43 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 20:47:46 -0400
commitbd5fe6c5eb9c548d7f07fe8f89a150bb6705e8e3 (patch)
treeef5341c7747f809aec7ae233f6e3ef90af39be5f /fs/attr.c
parentf9b5570d7fdedff32a2e78102bfb54cd1b12b289 (diff)
fs: kill i_alloc_sem
i_alloc_sem is a rather special rw_semaphore. It's the last one that may be released by a non-owner, and it's write side is always mirrored by real exclusion. It's intended use it to wait for all pending direct I/O requests to finish before starting a truncate. Replace it with a hand-grown construct: - exclusion for truncates is already guaranteed by i_mutex, so it can simply fall way - the reader side is replaced by an i_dio_count member in struct inode that counts the number of pending direct I/O requests. Truncate can't proceed as long as it's non-zero - when i_dio_count reaches non-zero we wake up a pending truncate using wake_up_bit on a new bit in i_flags - new references to i_dio_count can't appear while we are waiting for it to read zero because the direct I/O count always needs i_mutex (or an equivalent like XFS's i_iolock) for starting a new operation. This scheme is much simpler, and saves the space of a spinlock_t and a struct list_head in struct inode (typically 160 bits on a non-debug 64-bit system). Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/attr.c')
-rw-r--r--fs/attr.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/fs/attr.c b/fs/attr.c
index caf2aa521e2b..f177ac86fa48 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -233,16 +233,13 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
233 return error; 233 return error;
234 234
235 if (ia_valid & ATTR_SIZE) 235 if (ia_valid & ATTR_SIZE)
236 down_write(&dentry->d_inode->i_alloc_sem); 236 inode_dio_wait(inode);
237 237
238 if (inode->i_op->setattr) 238 if (inode->i_op->setattr)
239 error = inode->i_op->setattr(dentry, attr); 239 error = inode->i_op->setattr(dentry, attr);
240 else 240 else
241 error = simple_setattr(dentry, attr); 241 error = simple_setattr(dentry, attr);
242 242
243 if (ia_valid & ATTR_SIZE)
244 up_write(&dentry->d_inode->i_alloc_sem);
245
246 if (!error) 243 if (!error)
247 fsnotify_change(dentry, ia_valid); 244 fsnotify_change(dentry, ia_valid);
248 245