diff options
author | Dave Kleikamp <dave.kleikamp@oracle.com> | 2015-07-15 14:53:19 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.com> | 2015-07-23 14:59:39 -0400 |
commit | acc84b05b1f463952a638689335ca47e70d5ea30 (patch) | |
tree | 477ad20902b4f9d3595950002d429808c1387c30 /fs/jfs/namei.c | |
parent | 2e6c97ea4ce6a29941da46d03183c2c0e330fb2f (diff) |
jfs: Handle error from dquot_initialize()
dquot_initialize() can now return error. Handle it where possible
Slightly modified by Dave Kleikamp due to needed jfs_rename() error path
fix.
Signed-off-by: Jan Kara <jack@suse.com>
Reviewed-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Diffstat (limited to 'fs/jfs/namei.c')
-rw-r--r-- | fs/jfs/namei.c | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index a5ac97b9a933..35976bdccafc 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -86,7 +86,9 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode, | |||
86 | 86 | ||
87 | jfs_info("jfs_create: dip:0x%p name:%pd", dip, dentry); | 87 | jfs_info("jfs_create: dip:0x%p name:%pd", dip, dentry); |
88 | 88 | ||
89 | dquot_initialize(dip); | 89 | rc = dquot_initialize(dip); |
90 | if (rc) | ||
91 | goto out1; | ||
90 | 92 | ||
91 | /* | 93 | /* |
92 | * search parent directory for entry/freespace | 94 | * search parent directory for entry/freespace |
@@ -218,7 +220,9 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode) | |||
218 | 220 | ||
219 | jfs_info("jfs_mkdir: dip:0x%p name:%pd", dip, dentry); | 221 | jfs_info("jfs_mkdir: dip:0x%p name:%pd", dip, dentry); |
220 | 222 | ||
221 | dquot_initialize(dip); | 223 | rc = dquot_initialize(dip); |
224 | if (rc) | ||
225 | goto out1; | ||
222 | 226 | ||
223 | /* | 227 | /* |
224 | * search parent directory for entry/freespace | 228 | * search parent directory for entry/freespace |
@@ -355,8 +359,12 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) | |||
355 | jfs_info("jfs_rmdir: dip:0x%p name:%pd", dip, dentry); | 359 | jfs_info("jfs_rmdir: dip:0x%p name:%pd", dip, dentry); |
356 | 360 | ||
357 | /* Init inode for quota operations. */ | 361 | /* Init inode for quota operations. */ |
358 | dquot_initialize(dip); | 362 | rc = dquot_initialize(dip); |
359 | dquot_initialize(ip); | 363 | if (rc) |
364 | goto out; | ||
365 | rc = dquot_initialize(ip); | ||
366 | if (rc) | ||
367 | goto out; | ||
360 | 368 | ||
361 | /* directory must be empty to be removed */ | 369 | /* directory must be empty to be removed */ |
362 | if (!dtEmpty(ip)) { | 370 | if (!dtEmpty(ip)) { |
@@ -483,8 +491,12 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) | |||
483 | jfs_info("jfs_unlink: dip:0x%p name:%pd", dip, dentry); | 491 | jfs_info("jfs_unlink: dip:0x%p name:%pd", dip, dentry); |
484 | 492 | ||
485 | /* Init inode for quota operations. */ | 493 | /* Init inode for quota operations. */ |
486 | dquot_initialize(dip); | 494 | rc = dquot_initialize(dip); |
487 | dquot_initialize(ip); | 495 | if (rc) |
496 | goto out; | ||
497 | rc = dquot_initialize(ip); | ||
498 | if (rc) | ||
499 | goto out; | ||
488 | 500 | ||
489 | if ((rc = get_UCSname(&dname, dentry))) | 501 | if ((rc = get_UCSname(&dname, dentry))) |
490 | goto out; | 502 | goto out; |
@@ -799,7 +811,9 @@ static int jfs_link(struct dentry *old_dentry, | |||
799 | 811 | ||
800 | jfs_info("jfs_link: %pd %pd", old_dentry, dentry); | 812 | jfs_info("jfs_link: %pd %pd", old_dentry, dentry); |
801 | 813 | ||
802 | dquot_initialize(dir); | 814 | rc = dquot_initialize(dir); |
815 | if (rc) | ||
816 | goto out; | ||
803 | 817 | ||
804 | tid = txBegin(ip->i_sb, 0); | 818 | tid = txBegin(ip->i_sb, 0); |
805 | 819 | ||
@@ -810,7 +824,7 @@ static int jfs_link(struct dentry *old_dentry, | |||
810 | * scan parent directory for entry/freespace | 824 | * scan parent directory for entry/freespace |
811 | */ | 825 | */ |
812 | if ((rc = get_UCSname(&dname, dentry))) | 826 | if ((rc = get_UCSname(&dname, dentry))) |
813 | goto out; | 827 | goto out_tx; |
814 | 828 | ||
815 | if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) | 829 | if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) |
816 | goto free_dname; | 830 | goto free_dname; |
@@ -842,12 +856,13 @@ static int jfs_link(struct dentry *old_dentry, | |||
842 | free_dname: | 856 | free_dname: |
843 | free_UCSname(&dname); | 857 | free_UCSname(&dname); |
844 | 858 | ||
845 | out: | 859 | out_tx: |
846 | txEnd(tid); | 860 | txEnd(tid); |
847 | 861 | ||
848 | mutex_unlock(&JFS_IP(ip)->commit_mutex); | 862 | mutex_unlock(&JFS_IP(ip)->commit_mutex); |
849 | mutex_unlock(&JFS_IP(dir)->commit_mutex); | 863 | mutex_unlock(&JFS_IP(dir)->commit_mutex); |
850 | 864 | ||
865 | out: | ||
851 | jfs_info("jfs_link: rc:%d", rc); | 866 | jfs_info("jfs_link: rc:%d", rc); |
852 | return rc; | 867 | return rc; |
853 | } | 868 | } |
@@ -891,7 +906,9 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, | |||
891 | 906 | ||
892 | jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name); | 907 | jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name); |
893 | 908 | ||
894 | dquot_initialize(dip); | 909 | rc = dquot_initialize(dip); |
910 | if (rc) | ||
911 | goto out1; | ||
895 | 912 | ||
896 | ssize = strlen(name) + 1; | 913 | ssize = strlen(name) + 1; |
897 | 914 | ||
@@ -1082,8 +1099,12 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1082 | 1099 | ||
1083 | jfs_info("jfs_rename: %pd %pd", old_dentry, new_dentry); | 1100 | jfs_info("jfs_rename: %pd %pd", old_dentry, new_dentry); |
1084 | 1101 | ||
1085 | dquot_initialize(old_dir); | 1102 | rc = dquot_initialize(old_dir); |
1086 | dquot_initialize(new_dir); | 1103 | if (rc) |
1104 | goto out1; | ||
1105 | rc = dquot_initialize(new_dir); | ||
1106 | if (rc) | ||
1107 | goto out1; | ||
1087 | 1108 | ||
1088 | old_ip = d_inode(old_dentry); | 1109 | old_ip = d_inode(old_dentry); |
1089 | new_ip = d_inode(new_dentry); | 1110 | new_ip = d_inode(new_dentry); |
@@ -1130,7 +1151,9 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1130 | } else if (new_ip) { | 1151 | } else if (new_ip) { |
1131 | IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL); | 1152 | IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL); |
1132 | /* Init inode for quota operations. */ | 1153 | /* Init inode for quota operations. */ |
1133 | dquot_initialize(new_ip); | 1154 | rc = dquot_initialize(new_ip); |
1155 | if (rc) | ||
1156 | goto out_unlock; | ||
1134 | } | 1157 | } |
1135 | 1158 | ||
1136 | /* | 1159 | /* |
@@ -1318,6 +1341,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1318 | 1341 | ||
1319 | clear_cflag(COMMIT_Stale, old_dir); | 1342 | clear_cflag(COMMIT_Stale, old_dir); |
1320 | } | 1343 | } |
1344 | out_unlock: | ||
1321 | if (new_ip && !S_ISDIR(new_ip->i_mode)) | 1345 | if (new_ip && !S_ISDIR(new_ip->i_mode)) |
1322 | IWRITE_UNLOCK(new_ip); | 1346 | IWRITE_UNLOCK(new_ip); |
1323 | out3: | 1347 | out3: |
@@ -1353,7 +1377,9 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, | |||
1353 | 1377 | ||
1354 | jfs_info("jfs_mknod: %pd", dentry); | 1378 | jfs_info("jfs_mknod: %pd", dentry); |
1355 | 1379 | ||
1356 | dquot_initialize(dir); | 1380 | rc = dquot_initialize(dir); |
1381 | if (rc) | ||
1382 | goto out; | ||
1357 | 1383 | ||
1358 | if ((rc = get_UCSname(&dname, dentry))) | 1384 | if ((rc = get_UCSname(&dname, dentry))) |
1359 | goto out; | 1385 | goto out; |