diff options
author | Sage Weil <sage@inktank.com> | 2013-08-09 12:57:58 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-08-09 20:55:48 -0400 |
commit | 2f75e9e17911524f294aa7b3bf0d7233f99a3218 (patch) | |
tree | 41d27b7e1c3b343d2a843e3ffe03b99cb1ee08f9 /fs/ceph | |
parent | 0e5dd45ce4c41d3e3857116a77f34f04c99e78ad (diff) |
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: Sage Weil <sage@inktank.com>
Reviewed-by: Jianpeng Ma <majianpeng@gmail.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/file.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 7478d5dbd1aa..a17ffe4ec3ca 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -710,13 +710,11 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
710 | &ceph_sb_to_client(inode->i_sb)->client->osdc; | 710 | &ceph_sb_to_client(inode->i_sb)->client->osdc; |
711 | ssize_t count, written = 0; | 711 | ssize_t count, written = 0; |
712 | int err, want, got; | 712 | int err, want, got; |
713 | bool hold_mutex; | ||
714 | 713 | ||
715 | if (ceph_snap(inode) != CEPH_NOSNAP) | 714 | if (ceph_snap(inode) != CEPH_NOSNAP) |
716 | return -EROFS; | 715 | return -EROFS; |
717 | 716 | ||
718 | mutex_lock(&inode->i_mutex); | 717 | mutex_lock(&inode->i_mutex); |
719 | hold_mutex = true; | ||
720 | 718 | ||
721 | err = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ); | 719 | err = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ); |
722 | if (err) | 720 | if (err) |
@@ -772,7 +770,6 @@ retry_snap: | |||
772 | inode, ceph_vinop(inode), | 770 | inode, ceph_vinop(inode), |
773 | pos, (unsigned)iov->iov_len); | 771 | pos, (unsigned)iov->iov_len); |
774 | mutex_lock(&inode->i_mutex); | 772 | mutex_lock(&inode->i_mutex); |
775 | hold_mutex = true; | ||
776 | goto retry_snap; | 773 | goto retry_snap; |
777 | } | 774 | } |
778 | } else { | 775 | } else { |
@@ -781,7 +778,6 @@ retry_snap: | |||
781 | count, 0); | 778 | count, 0); |
782 | mutex_unlock(&inode->i_mutex); | 779 | mutex_unlock(&inode->i_mutex); |
783 | } | 780 | } |
784 | hold_mutex = false; | ||
785 | 781 | ||
786 | if (written >= 0) { | 782 | if (written >= 0) { |
787 | int dirty; | 783 | int dirty; |
@@ -805,11 +801,12 @@ retry_snap: | |||
805 | written = err; | 801 | written = err; |
806 | } | 802 | } |
807 | 803 | ||
804 | goto out_unlocked; | ||
805 | |||
808 | out: | 806 | out: |
809 | if (hold_mutex) | 807 | mutex_unlock(&inode->i_mutex); |
810 | mutex_unlock(&inode->i_mutex); | 808 | out_unlocked: |
811 | current->backing_dev_info = NULL; | 809 | current->backing_dev_info = NULL; |
812 | |||
813 | return written ? written : err; | 810 | return written ? written : err; |
814 | } | 811 | } |
815 | 812 | ||