aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorMarco Stornelli <marco.stornelli@gmail.com>2012-10-06 06:40:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-09 23:33:38 -0400
commite40b34c7921534a46f7bae23ec6646d3d9c2c7b2 (patch)
tree84a7ffac7bce215827fbde733aad964a5e38eaa4 /fs/fat
parent67e2c19a3bcd32172c1d67294a1d6bb4bc60ca77 (diff)
fat: drop lock/unlock super
Removed lock/unlock super. Added a new private s_lock mutex. Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/dir.c4
-rw-r--r--fs/fat/fat.h5
-rw-r--r--fs/fat/inode.c5
-rw-r--r--fs/fat/namei_msdos.c26
-rw-r--r--fs/fat/namei_vfat.c30
5 files changed, 36 insertions, 34 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index bca6d0a1255e..2a182342442e 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -571,7 +571,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
571 int short_len = 0, fill_len = 0; 571 int short_len = 0, fill_len = 0;
572 int ret = 0; 572 int ret = 0;
573 573
574 lock_super(sb); 574 mutex_lock(&sbi->s_lock);
575 575
576 cpos = filp->f_pos; 576 cpos = filp->f_pos;
577 /* Fake . and .. for the root directory. */ 577 /* Fake . and .. for the root directory. */
@@ -693,7 +693,7 @@ fill_failed:
693 if (unicode) 693 if (unicode)
694 __putname(unicode); 694 __putname(unicode);
695out: 695out:
696 unlock_super(sb); 696 mutex_unlock(&sbi->s_lock);
697 return ret; 697 return ret;
698} 698}
699 699
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index ca7e8f8bad7c..623f36f0423b 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -71,8 +71,9 @@ struct msdos_sb_info {
71 unsigned long root_cluster; /* first cluster of the root directory */ 71 unsigned long root_cluster; /* first cluster of the root directory */
72 unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */ 72 unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
73 struct mutex fat_lock; 73 struct mutex fat_lock;
74 unsigned int prev_free; /* previously allocated cluster number */ 74 struct mutex s_lock;
75 unsigned int free_clusters; /* -1 if undefined */ 75 unsigned int prev_free; /* previously allocated cluster number */
76 unsigned int free_clusters; /* -1 if undefined */
76 unsigned int free_clus_valid; /* is free_clusters valid? */ 77 unsigned int free_clus_valid; /* is free_clusters valid? */
77 struct fat_mount_options options; 78 struct fat_mount_options options;
78 struct nls_table *nls_disk; /* Codepage used on disk */ 79 struct nls_table *nls_disk; /* Codepage used on disk */
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 76f60c642c06..5bafaad00530 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -673,9 +673,9 @@ static int fat_write_inode(struct inode *inode, struct writeback_control *wbc)
673 if (inode->i_ino == MSDOS_FSINFO_INO) { 673 if (inode->i_ino == MSDOS_FSINFO_INO) {
674 struct super_block *sb = inode->i_sb; 674 struct super_block *sb = inode->i_sb;
675 675
676 lock_super(sb); 676 mutex_lock(&MSDOS_SB(sb)->s_lock);
677 err = fat_clusters_flush(sb); 677 err = fat_clusters_flush(sb);
678 unlock_super(sb); 678 mutex_unlock(&MSDOS_SB(sb)->s_lock);
679 } else 679 } else
680 err = __fat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); 680 err = __fat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
681 681
@@ -1268,6 +1268,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1268 b = (struct fat_boot_sector *) bh->b_data; 1268 b = (struct fat_boot_sector *) bh->b_data;
1269 } 1269 }
1270 1270
1271 mutex_init(&sbi->s_lock);
1271 sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus; 1272 sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus;
1272 sbi->cluster_bits = ffs(sbi->cluster_size) - 1; 1273 sbi->cluster_bits = ffs(sbi->cluster_size) - 1;
1273 sbi->fats = b->fats; 1274 sbi->fats = b->fats;
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index c1055e778fff..e2cfda94a28d 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -208,7 +208,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
208 struct inode *inode; 208 struct inode *inode;
209 int err; 209 int err;
210 210
211 lock_super(sb); 211 mutex_lock(&MSDOS_SB(sb)->s_lock);
212 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); 212 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
213 switch (err) { 213 switch (err) {
214 case -ENOENT: 214 case -ENOENT:
@@ -221,7 +221,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
221 default: 221 default:
222 inode = ERR_PTR(err); 222 inode = ERR_PTR(err);
223 } 223 }
224 unlock_super(sb); 224 mutex_unlock(&MSDOS_SB(sb)->s_lock);
225 return d_splice_alias(inode, dentry); 225 return d_splice_alias(inode, dentry);
226} 226}
227 227
@@ -273,7 +273,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
273 unsigned char msdos_name[MSDOS_NAME]; 273 unsigned char msdos_name[MSDOS_NAME];
274 int err, is_hid; 274 int err, is_hid;
275 275
276 lock_super(sb); 276 mutex_lock(&MSDOS_SB(sb)->s_lock);
277 277
278 err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, 278 err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
279 msdos_name, &MSDOS_SB(sb)->options); 279 msdos_name, &MSDOS_SB(sb)->options);
@@ -302,7 +302,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
302 302
303 d_instantiate(dentry, inode); 303 d_instantiate(dentry, inode);
304out: 304out:
305 unlock_super(sb); 305 mutex_unlock(&MSDOS_SB(sb)->s_lock);
306 if (!err) 306 if (!err)
307 err = fat_flush_inodes(sb, dir, inode); 307 err = fat_flush_inodes(sb, dir, inode);
308 return err; 308 return err;
@@ -316,7 +316,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
316 struct fat_slot_info sinfo; 316 struct fat_slot_info sinfo;
317 int err; 317 int err;
318 318
319 lock_super(sb); 319 mutex_lock(&MSDOS_SB(sb)->s_lock);
320 /* 320 /*
321 * Check whether the directory is not in use, then check 321 * Check whether the directory is not in use, then check
322 * whether it is empty. 322 * whether it is empty.
@@ -337,7 +337,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
337 inode->i_ctime = CURRENT_TIME_SEC; 337 inode->i_ctime = CURRENT_TIME_SEC;
338 fat_detach(inode); 338 fat_detach(inode);
339out: 339out:
340 unlock_super(sb); 340 mutex_unlock(&MSDOS_SB(sb)->s_lock);
341 if (!err) 341 if (!err)
342 err = fat_flush_inodes(sb, dir, inode); 342 err = fat_flush_inodes(sb, dir, inode);
343 343
@@ -354,7 +354,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
354 struct timespec ts; 354 struct timespec ts;
355 int err, is_hid, cluster; 355 int err, is_hid, cluster;
356 356
357 lock_super(sb); 357 mutex_lock(&MSDOS_SB(sb)->s_lock);
358 358
359 err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, 359 err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
360 msdos_name, &MSDOS_SB(sb)->options); 360 msdos_name, &MSDOS_SB(sb)->options);
@@ -392,14 +392,14 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
392 392
393 d_instantiate(dentry, inode); 393 d_instantiate(dentry, inode);
394 394
395 unlock_super(sb); 395 mutex_unlock(&MSDOS_SB(sb)->s_lock);
396 fat_flush_inodes(sb, dir, inode); 396 fat_flush_inodes(sb, dir, inode);
397 return 0; 397 return 0;
398 398
399out_free: 399out_free:
400 fat_free_clusters(dir, cluster); 400 fat_free_clusters(dir, cluster);
401out: 401out:
402 unlock_super(sb); 402 mutex_unlock(&MSDOS_SB(sb)->s_lock);
403 return err; 403 return err;
404} 404}
405 405
@@ -411,7 +411,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
411 struct fat_slot_info sinfo; 411 struct fat_slot_info sinfo;
412 int err; 412 int err;
413 413
414 lock_super(sb); 414 mutex_lock(&MSDOS_SB(sb)->s_lock);
415 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); 415 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
416 if (err) 416 if (err)
417 goto out; 417 goto out;
@@ -423,7 +423,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
423 inode->i_ctime = CURRENT_TIME_SEC; 423 inode->i_ctime = CURRENT_TIME_SEC;
424 fat_detach(inode); 424 fat_detach(inode);
425out: 425out:
426 unlock_super(sb); 426 mutex_unlock(&MSDOS_SB(sb)->s_lock);
427 if (!err) 427 if (!err)
428 err = fat_flush_inodes(sb, dir, inode); 428 err = fat_flush_inodes(sb, dir, inode);
429 429
@@ -606,7 +606,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
606 unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME]; 606 unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
607 int err, is_hid; 607 int err, is_hid;
608 608
609 lock_super(sb); 609 mutex_lock(&MSDOS_SB(sb)->s_lock);
610 610
611 err = msdos_format_name(old_dentry->d_name.name, 611 err = msdos_format_name(old_dentry->d_name.name,
612 old_dentry->d_name.len, old_msdos_name, 612 old_dentry->d_name.len, old_msdos_name,
@@ -625,7 +625,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
625 err = do_msdos_rename(old_dir, old_msdos_name, old_dentry, 625 err = do_msdos_rename(old_dir, old_msdos_name, old_dentry,
626 new_dir, new_msdos_name, new_dentry, is_hid); 626 new_dir, new_msdos_name, new_dentry, is_hid);
627out: 627out:
628 unlock_super(sb); 628 mutex_unlock(&MSDOS_SB(sb)->s_lock);
629 if (!err) 629 if (!err)
630 err = fat_flush_inodes(sb, old_dir, new_dir); 630 err = fat_flush_inodes(sb, old_dir, new_dir);
631 return err; 631 return err;
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index e535dd75b986..ac959d655e7d 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -721,7 +721,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
721 struct dentry *alias; 721 struct dentry *alias;
722 int err; 722 int err;
723 723
724 lock_super(sb); 724 mutex_lock(&MSDOS_SB(sb)->s_lock);
725 725
726 err = vfat_find(dir, &dentry->d_name, &sinfo); 726 err = vfat_find(dir, &dentry->d_name, &sinfo);
727 if (err) { 727 if (err) {
@@ -752,13 +752,13 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
752 if (!S_ISDIR(inode->i_mode)) 752 if (!S_ISDIR(inode->i_mode))
753 d_move(alias, dentry); 753 d_move(alias, dentry);
754 iput(inode); 754 iput(inode);
755 unlock_super(sb); 755 mutex_unlock(&MSDOS_SB(sb)->s_lock);
756 return alias; 756 return alias;
757 } else 757 } else
758 dput(alias); 758 dput(alias);
759 759
760out: 760out:
761 unlock_super(sb); 761 mutex_unlock(&MSDOS_SB(sb)->s_lock);
762 dentry->d_time = dentry->d_parent->d_inode->i_version; 762 dentry->d_time = dentry->d_parent->d_inode->i_version;
763 dentry = d_splice_alias(inode, dentry); 763 dentry = d_splice_alias(inode, dentry);
764 if (dentry) 764 if (dentry)
@@ -766,7 +766,7 @@ out:
766 return dentry; 766 return dentry;
767 767
768error: 768error:
769 unlock_super(sb); 769 mutex_unlock(&MSDOS_SB(sb)->s_lock);
770 return ERR_PTR(err); 770 return ERR_PTR(err);
771} 771}
772 772
@@ -779,7 +779,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
779 struct timespec ts; 779 struct timespec ts;
780 int err; 780 int err;
781 781
782 lock_super(sb); 782 mutex_lock(&MSDOS_SB(sb)->s_lock);
783 783
784 ts = CURRENT_TIME_SEC; 784 ts = CURRENT_TIME_SEC;
785 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo); 785 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
@@ -800,7 +800,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
800 dentry->d_time = dentry->d_parent->d_inode->i_version; 800 dentry->d_time = dentry->d_parent->d_inode->i_version;
801 d_instantiate(dentry, inode); 801 d_instantiate(dentry, inode);
802out: 802out:
803 unlock_super(sb); 803 mutex_unlock(&MSDOS_SB(sb)->s_lock);
804 return err; 804 return err;
805} 805}
806 806
@@ -811,7 +811,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
811 struct fat_slot_info sinfo; 811 struct fat_slot_info sinfo;
812 int err; 812 int err;
813 813
814 lock_super(sb); 814 mutex_lock(&MSDOS_SB(sb)->s_lock);
815 815
816 err = fat_dir_empty(inode); 816 err = fat_dir_empty(inode);
817 if (err) 817 if (err)
@@ -829,7 +829,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
829 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 829 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
830 fat_detach(inode); 830 fat_detach(inode);
831out: 831out:
832 unlock_super(sb); 832 mutex_unlock(&MSDOS_SB(sb)->s_lock);
833 833
834 return err; 834 return err;
835} 835}
@@ -841,7 +841,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
841 struct fat_slot_info sinfo; 841 struct fat_slot_info sinfo;
842 int err; 842 int err;
843 843
844 lock_super(sb); 844 mutex_lock(&MSDOS_SB(sb)->s_lock);
845 845
846 err = vfat_find(dir, &dentry->d_name, &sinfo); 846 err = vfat_find(dir, &dentry->d_name, &sinfo);
847 if (err) 847 if (err)
@@ -854,7 +854,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
854 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 854 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
855 fat_detach(inode); 855 fat_detach(inode);
856out: 856out:
857 unlock_super(sb); 857 mutex_unlock(&MSDOS_SB(sb)->s_lock);
858 858
859 return err; 859 return err;
860} 860}
@@ -867,7 +867,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
867 struct timespec ts; 867 struct timespec ts;
868 int err, cluster; 868 int err, cluster;
869 869
870 lock_super(sb); 870 mutex_lock(&MSDOS_SB(sb)->s_lock);
871 871
872 ts = CURRENT_TIME_SEC; 872 ts = CURRENT_TIME_SEC;
873 cluster = fat_alloc_new_dir(dir, &ts); 873 cluster = fat_alloc_new_dir(dir, &ts);
@@ -896,13 +896,13 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
896 dentry->d_time = dentry->d_parent->d_inode->i_version; 896 dentry->d_time = dentry->d_parent->d_inode->i_version;
897 d_instantiate(dentry, inode); 897 d_instantiate(dentry, inode);
898 898
899 unlock_super(sb); 899 mutex_unlock(&MSDOS_SB(sb)->s_lock);
900 return 0; 900 return 0;
901 901
902out_free: 902out_free:
903 fat_free_clusters(dir, cluster); 903 fat_free_clusters(dir, cluster);
904out: 904out:
905 unlock_super(sb); 905 mutex_unlock(&MSDOS_SB(sb)->s_lock);
906 return err; 906 return err;
907} 907}
908 908
@@ -921,7 +921,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
921 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; 921 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
922 old_inode = old_dentry->d_inode; 922 old_inode = old_dentry->d_inode;
923 new_inode = new_dentry->d_inode; 923 new_inode = new_dentry->d_inode;
924 lock_super(sb); 924 mutex_lock(&MSDOS_SB(sb)->s_lock);
925 err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo); 925 err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo);
926 if (err) 926 if (err)
927 goto out; 927 goto out;
@@ -996,7 +996,7 @@ out:
996 brelse(sinfo.bh); 996 brelse(sinfo.bh);
997 brelse(dotdot_bh); 997 brelse(dotdot_bh);
998 brelse(old_sinfo.bh); 998 brelse(old_sinfo.bh);
999 unlock_super(sb); 999 mutex_unlock(&MSDOS_SB(sb)->s_lock);
1000 1000
1001 return err; 1001 return err;
1002 1002