diff options
author | Jeff Mahoney <jeffm@suse.com> | 2013-08-08 17:34:46 -0400 |
---|---|---|
committer | Jeff Mahoney <jeffm@suse.de> | 2013-08-08 17:34:46 -0400 |
commit | 278f6679f454bf185a07d9a4ca355b153482d17a (patch) | |
tree | ffead073e67cfdc1ddfc3949ebc93c06dcaaab8f /fs/reiserfs/ioctl.c | |
parent | 4c05141df57f4ffc1a9a28f1925434924179bfe4 (diff) |
reiserfs: locking, handle nested locks properly
The reiserfs write lock replaced the BKL and uses similar semantics.
Frederic's locking code makes a distinction between when the lock is nested
and when it's being acquired/released, but I don't think that's the right
distinction to make.
The right distinction is between the lock being released at end-of-use and
the lock being released for a schedule. The unlock should return the depth
and the lock should restore it, rather than the other way around as it is now.
This patch implements that and adds a number of places where the lock
should be dropped.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Diffstat (limited to 'fs/reiserfs/ioctl.c')
-rw-r--r-- | fs/reiserfs/ioctl.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index 15cb5fe6b425..946ccbf5b5a1 100644 --- a/fs/reiserfs/ioctl.c +++ b/fs/reiserfs/ioctl.c | |||
@@ -167,7 +167,6 @@ int reiserfs_commit_write(struct file *f, struct page *page, | |||
167 | int reiserfs_unpack(struct inode *inode, struct file *filp) | 167 | int reiserfs_unpack(struct inode *inode, struct file *filp) |
168 | { | 168 | { |
169 | int retval = 0; | 169 | int retval = 0; |
170 | int depth; | ||
171 | int index; | 170 | int index; |
172 | struct page *page; | 171 | struct page *page; |
173 | struct address_space *mapping; | 172 | struct address_space *mapping; |
@@ -183,11 +182,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp) | |||
183 | return 0; | 182 | return 0; |
184 | } | 183 | } |
185 | 184 | ||
186 | depth = reiserfs_write_lock_once(inode->i_sb); | ||
187 | |||
188 | /* we need to make sure nobody is changing the file size beneath us */ | 185 | /* we need to make sure nobody is changing the file size beneath us */ |
189 | reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb); | 186 | reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb); |
190 | 187 | ||
188 | reiserfs_write_lock(inode->i_sb); | ||
189 | |||
191 | write_from = inode->i_size & (blocksize - 1); | 190 | write_from = inode->i_size & (blocksize - 1); |
192 | /* if we are on a block boundary, we are already unpacked. */ | 191 | /* if we are on a block boundary, we are already unpacked. */ |
193 | if (write_from == 0) { | 192 | if (write_from == 0) { |
@@ -221,6 +220,6 @@ int reiserfs_unpack(struct inode *inode, struct file *filp) | |||
221 | 220 | ||
222 | out: | 221 | out: |
223 | mutex_unlock(&inode->i_mutex); | 222 | mutex_unlock(&inode->i_mutex); |
224 | reiserfs_write_unlock_once(inode->i_sb, depth); | 223 | reiserfs_write_unlock(inode->i_sb); |
225 | return retval; | 224 | return retval; |
226 | } | 225 | } |