aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes-kernel@saeurebad.de>2007-07-16 02:41:25 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:50 -0400
commit4e91672c76319aaed24ea3e784e238cf445c57cb (patch)
treecabe2885ede89b832e147fb32404cc2a22ddf30c
parent948730b0e39fb4cba4a5ed0fc40e0f017cce2dfa (diff)
Replace obscure constructs in fs/block_dev.c
Replace some funky codepaths in fs/block_dev.c with cleaner versions of the affected places. [akpm@linux-foundation.org: fix return value] Signed-off-by: Johannes Weiner <hannes-kernel@saeurebad.de> Cc: Bjorn Steinbrink <B.Steinbrink@gmx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/block_dev.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index da5f0515e8eb..75c47a21b2f0 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -872,7 +872,7 @@ static struct bd_holder *find_bd_holder(struct block_device *bdev,
872 */ 872 */
873static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo) 873static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo)
874{ 874{
875 int ret; 875 int err;
876 876
877 if (!bo) 877 if (!bo)
878 return -EINVAL; 878 return -EINVAL;
@@ -880,15 +880,18 @@ static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo)
880 if (!bd_holder_grab_dirs(bdev, bo)) 880 if (!bd_holder_grab_dirs(bdev, bo))
881 return -EBUSY; 881 return -EBUSY;
882 882
883 ret = add_symlink(bo->sdir, bo->sdev); 883 err = add_symlink(bo->sdir, bo->sdev);
884 if (ret == 0) { 884 if (err)
885 ret = add_symlink(bo->hdir, bo->hdev); 885 return err;
886 if (ret) 886
887 del_symlink(bo->sdir, bo->sdev); 887 err = add_symlink(bo->hdir, bo->hdev);
888 if (err) {
889 del_symlink(bo->sdir, bo->sdev);
890 return err;
888 } 891 }
889 if (ret == 0) 892
890 list_add_tail(&bo->list, &bdev->bd_holder_list); 893 list_add_tail(&bo->list, &bdev->bd_holder_list);
891 return ret; 894 return 0;
892} 895}
893 896
894/** 897/**
@@ -946,7 +949,7 @@ static struct bd_holder *del_bd_holder(struct block_device *bdev,
946static int bd_claim_by_kobject(struct block_device *bdev, void *holder, 949static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
947 struct kobject *kobj) 950 struct kobject *kobj)
948{ 951{
949 int res; 952 int err;
950 struct bd_holder *bo, *found; 953 struct bd_holder *bo, *found;
951 954
952 if (!kobj) 955 if (!kobj)
@@ -957,21 +960,24 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
957 return -ENOMEM; 960 return -ENOMEM;
958 961
959 mutex_lock(&bdev->bd_mutex); 962 mutex_lock(&bdev->bd_mutex);
960 res = bd_claim(bdev, holder);
961 if (res == 0) {
962 found = find_bd_holder(bdev, bo);
963 if (found == NULL) {
964 res = add_bd_holder(bdev, bo);
965 if (res)
966 bd_release(bdev);
967 }
968 }
969 963
970 if (res || found) 964 err = bd_claim(bdev, holder);
965 if (err)
966 goto out;
967
968 found = find_bd_holder(bdev, bo);
969 if (found)
970 goto out;
971
972 err = add_bd_holder(bdev, bo);
973 if (err)
974 bd_release(bdev);
975
976out:
977 if (err || found)
971 free_bd_holder(bo); 978 free_bd_holder(bo);
972 mutex_unlock(&bdev->bd_mutex); 979 mutex_unlock(&bdev->bd_mutex);
973 980 return err;
974 return res;
975} 981}
976 982
977/** 983/**