Commit 2f75e9e1 authored by Sage Weil's avatar Sage Weil

ceph: replace hold_mutex flag with goto

All of the early exit paths need to drop the mutex; it is only the normal
path through the function that does not.  Skip the unlock in that case
with a goto out_unlocked.
Signed-off-by: default avatarSage Weil <sage@inktank.com>
Reviewed-by: default avatarJianpeng Ma <majianpeng@gmail.com>
parent 0e5dd45c
...@@ -710,13 +710,11 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -710,13 +710,11 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
&ceph_sb_to_client(inode->i_sb)->client->osdc; &ceph_sb_to_client(inode->i_sb)->client->osdc;
ssize_t count, written = 0; ssize_t count, written = 0;
int err, want, got; int err, want, got;
bool hold_mutex;
if (ceph_snap(inode) != CEPH_NOSNAP) if (ceph_snap(inode) != CEPH_NOSNAP)
return -EROFS; return -EROFS;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
hold_mutex = true;
err = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ); err = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ);
if (err) if (err)
...@@ -772,7 +770,6 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -772,7 +770,6 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
inode, ceph_vinop(inode), inode, ceph_vinop(inode),
pos, (unsigned)iov->iov_len); pos, (unsigned)iov->iov_len);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
hold_mutex = true;
goto retry_snap; goto retry_snap;
} }
} else { } else {
...@@ -781,7 +778,6 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -781,7 +778,6 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
count, 0); count, 0);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
} }
hold_mutex = false;
if (written >= 0) { if (written >= 0) {
int dirty; int dirty;
...@@ -805,11 +801,12 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -805,11 +801,12 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
written = err; written = err;
} }
goto out_unlocked;
out: out:
if (hold_mutex)
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
out_unlocked:
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
return written ? written : err; return written ? written : err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment