diff options
Diffstat (limited to 'fs/gfs2/super.c')
-rw-r--r-- | fs/gfs2/super.c | 219 |
1 files changed, 184 insertions, 35 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 77cb9f830ee4..fb0edf735483 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/time.h> | 23 | #include <linux/time.h> |
24 | #include <linux/wait.h> | 24 | #include <linux/wait.h> |
25 | #include <linux/writeback.h> | 25 | #include <linux/writeback.h> |
26 | #include <linux/backing-dev.h> | ||
26 | 27 | ||
27 | #include "gfs2.h" | 28 | #include "gfs2.h" |
28 | #include "incore.h" | 29 | #include "incore.h" |
@@ -85,6 +86,7 @@ static const match_table_t tokens = { | |||
85 | {Opt_locktable, "locktable=%s"}, | 86 | {Opt_locktable, "locktable=%s"}, |
86 | {Opt_hostdata, "hostdata=%s"}, | 87 | {Opt_hostdata, "hostdata=%s"}, |
87 | {Opt_spectator, "spectator"}, | 88 | {Opt_spectator, "spectator"}, |
89 | {Opt_spectator, "norecovery"}, | ||
88 | {Opt_ignore_local_fs, "ignore_local_fs"}, | 90 | {Opt_ignore_local_fs, "ignore_local_fs"}, |
89 | {Opt_localflocks, "localflocks"}, | 91 | {Opt_localflocks, "localflocks"}, |
90 | {Opt_localcaching, "localcaching"}, | 92 | {Opt_localcaching, "localcaching"}, |
@@ -159,13 +161,13 @@ int gfs2_mount_args(struct gfs2_args *args, char *options) | |||
159 | args->ar_spectator = 1; | 161 | args->ar_spectator = 1; |
160 | break; | 162 | break; |
161 | case Opt_ignore_local_fs: | 163 | case Opt_ignore_local_fs: |
162 | args->ar_ignore_local_fs = 1; | 164 | /* Retained for backwards compat only */ |
163 | break; | 165 | break; |
164 | case Opt_localflocks: | 166 | case Opt_localflocks: |
165 | args->ar_localflocks = 1; | 167 | args->ar_localflocks = 1; |
166 | break; | 168 | break; |
167 | case Opt_localcaching: | 169 | case Opt_localcaching: |
168 | args->ar_localcaching = 1; | 170 | /* Retained for backwards compat only */ |
169 | break; | 171 | break; |
170 | case Opt_debug: | 172 | case Opt_debug: |
171 | if (args->ar_errors == GFS2_ERRORS_PANIC) { | 173 | if (args->ar_errors == GFS2_ERRORS_PANIC) { |
@@ -179,7 +181,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options) | |||
179 | args->ar_debug = 0; | 181 | args->ar_debug = 0; |
180 | break; | 182 | break; |
181 | case Opt_upgrade: | 183 | case Opt_upgrade: |
182 | args->ar_upgrade = 1; | 184 | /* Retained for backwards compat only */ |
183 | break; | 185 | break; |
184 | case Opt_acl: | 186 | case Opt_acl: |
185 | args->ar_posix_acl = 1; | 187 | args->ar_posix_acl = 1; |
@@ -342,15 +344,14 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd) | |||
342 | { | 344 | { |
343 | struct gfs2_inode *ip = GFS2_I(jd->jd_inode); | 345 | struct gfs2_inode *ip = GFS2_I(jd->jd_inode); |
344 | struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); | 346 | struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); |
347 | u64 size = i_size_read(jd->jd_inode); | ||
345 | 348 | ||
346 | if (ip->i_disksize < (8 << 20) || ip->i_disksize > (1 << 30) || | 349 | if (gfs2_check_internal_file_size(jd->jd_inode, 8 << 20, 1 << 30)) |
347 | (ip->i_disksize & (sdp->sd_sb.sb_bsize - 1))) { | ||
348 | gfs2_consist_inode(ip); | ||
349 | return -EIO; | 350 | return -EIO; |
350 | } | ||
351 | jd->jd_blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; | ||
352 | 351 | ||
353 | if (gfs2_write_alloc_required(ip, 0, ip->i_disksize)) { | 352 | jd->jd_blocks = size >> sdp->sd_sb.sb_bsize_shift; |
353 | |||
354 | if (gfs2_write_alloc_required(ip, 0, size)) { | ||
354 | gfs2_consist_inode(ip); | 355 | gfs2_consist_inode(ip); |
355 | return -EIO; | 356 | return -EIO; |
356 | } | 357 | } |
@@ -657,7 +658,7 @@ out: | |||
657 | * @sdp: the file system | 658 | * @sdp: the file system |
658 | * | 659 | * |
659 | * This function flushes data and meta data for all machines by | 660 | * This function flushes data and meta data for all machines by |
660 | * aquiring the transaction log exclusively. All journals are | 661 | * acquiring the transaction log exclusively. All journals are |
661 | * ensured to be in a clean state as well. | 662 | * ensured to be in a clean state as well. |
662 | * | 663 | * |
663 | * Returns: errno | 664 | * Returns: errno |
@@ -700,11 +701,47 @@ void gfs2_unfreeze_fs(struct gfs2_sbd *sdp) | |||
700 | mutex_unlock(&sdp->sd_freeze_lock); | 701 | mutex_unlock(&sdp->sd_freeze_lock); |
701 | } | 702 | } |
702 | 703 | ||
704 | void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) | ||
705 | { | ||
706 | struct gfs2_dinode *str = buf; | ||
707 | |||
708 | str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | ||
709 | str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI); | ||
710 | str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI); | ||
711 | str->di_num.no_addr = cpu_to_be64(ip->i_no_addr); | ||
712 | str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); | ||
713 | str->di_mode = cpu_to_be32(ip->i_inode.i_mode); | ||
714 | str->di_uid = cpu_to_be32(ip->i_inode.i_uid); | ||
715 | str->di_gid = cpu_to_be32(ip->i_inode.i_gid); | ||
716 | str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); | ||
717 | str->di_size = cpu_to_be64(i_size_read(&ip->i_inode)); | ||
718 | str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); | ||
719 | str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); | ||
720 | str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); | ||
721 | str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec); | ||
722 | |||
723 | str->di_goal_meta = cpu_to_be64(ip->i_goal); | ||
724 | str->di_goal_data = cpu_to_be64(ip->i_goal); | ||
725 | str->di_generation = cpu_to_be64(ip->i_generation); | ||
726 | |||
727 | str->di_flags = cpu_to_be32(ip->i_diskflags); | ||
728 | str->di_height = cpu_to_be16(ip->i_height); | ||
729 | str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && | ||
730 | !(ip->i_diskflags & GFS2_DIF_EXHASH) ? | ||
731 | GFS2_FORMAT_DE : 0); | ||
732 | str->di_depth = cpu_to_be16(ip->i_depth); | ||
733 | str->di_entries = cpu_to_be32(ip->i_entries); | ||
734 | |||
735 | str->di_eattr = cpu_to_be64(ip->i_eattr); | ||
736 | str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); | ||
737 | str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec); | ||
738 | str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec); | ||
739 | } | ||
703 | 740 | ||
704 | /** | 741 | /** |
705 | * gfs2_write_inode - Make sure the inode is stable on the disk | 742 | * gfs2_write_inode - Make sure the inode is stable on the disk |
706 | * @inode: The inode | 743 | * @inode: The inode |
707 | * @sync: synchronous write flag | 744 | * @wbc: The writeback control structure |
708 | * | 745 | * |
709 | * Returns: errno | 746 | * Returns: errno |
710 | */ | 747 | */ |
@@ -713,18 +750,24 @@ static int gfs2_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
713 | { | 750 | { |
714 | struct gfs2_inode *ip = GFS2_I(inode); | 751 | struct gfs2_inode *ip = GFS2_I(inode); |
715 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 752 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
753 | struct address_space *metamapping = gfs2_glock2aspace(ip->i_gl); | ||
754 | struct backing_dev_info *bdi = metamapping->backing_dev_info; | ||
716 | struct gfs2_holder gh; | 755 | struct gfs2_holder gh; |
717 | struct buffer_head *bh; | 756 | struct buffer_head *bh; |
718 | struct timespec atime; | 757 | struct timespec atime; |
719 | struct gfs2_dinode *di; | 758 | struct gfs2_dinode *di; |
720 | int ret = 0; | 759 | int ret = -EAGAIN; |
760 | int unlock_required = 0; | ||
721 | 761 | ||
722 | /* Check this is a "normal" inode, etc */ | 762 | /* Skip timestamp update, if this is from a memalloc */ |
723 | if (current->flags & PF_MEMALLOC) | 763 | if (current->flags & PF_MEMALLOC) |
724 | return 0; | ||
725 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | ||
726 | if (ret) | ||
727 | goto do_flush; | 764 | goto do_flush; |
765 | if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { | ||
766 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | ||
767 | if (ret) | ||
768 | goto do_flush; | ||
769 | unlock_required = 1; | ||
770 | } | ||
728 | ret = gfs2_trans_begin(sdp, RES_DINODE, 0); | 771 | ret = gfs2_trans_begin(sdp, RES_DINODE, 0); |
729 | if (ret) | 772 | if (ret) |
730 | goto do_unlock; | 773 | goto do_unlock; |
@@ -741,10 +784,18 @@ static int gfs2_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
741 | } | 784 | } |
742 | gfs2_trans_end(sdp); | 785 | gfs2_trans_end(sdp); |
743 | do_unlock: | 786 | do_unlock: |
744 | gfs2_glock_dq_uninit(&gh); | 787 | if (unlock_required) |
788 | gfs2_glock_dq_uninit(&gh); | ||
745 | do_flush: | 789 | do_flush: |
746 | if (wbc->sync_mode == WB_SYNC_ALL) | 790 | if (wbc->sync_mode == WB_SYNC_ALL) |
747 | gfs2_log_flush(GFS2_SB(inode), ip->i_gl); | 791 | gfs2_log_flush(GFS2_SB(inode), ip->i_gl); |
792 | filemap_fdatawrite(metamapping); | ||
793 | if (bdi->dirty_exceeded) | ||
794 | gfs2_ail1_flush(sdp, wbc); | ||
795 | if (!ret && (wbc->sync_mode == WB_SYNC_ALL)) | ||
796 | ret = filemap_fdatawait(metamapping); | ||
797 | if (ret) | ||
798 | mark_inode_dirty_sync(inode); | ||
748 | return ret; | 799 | return ret; |
749 | } | 800 | } |
750 | 801 | ||
@@ -857,7 +908,6 @@ restart: | |||
857 | gfs2_clear_rgrpd(sdp); | 908 | gfs2_clear_rgrpd(sdp); |
858 | gfs2_jindex_free(sdp); | 909 | gfs2_jindex_free(sdp); |
859 | /* Take apart glock structures and buffer lists */ | 910 | /* Take apart glock structures and buffer lists */ |
860 | invalidate_inodes(sdp->sd_vfs); | ||
861 | gfs2_gl_hash_clear(sdp); | 911 | gfs2_gl_hash_clear(sdp); |
862 | /* Unmount the locking protocol */ | 912 | /* Unmount the locking protocol */ |
863 | gfs2_lm_unmount(sdp); | 913 | gfs2_lm_unmount(sdp); |
@@ -875,8 +925,9 @@ restart: | |||
875 | 925 | ||
876 | static int gfs2_sync_fs(struct super_block *sb, int wait) | 926 | static int gfs2_sync_fs(struct super_block *sb, int wait) |
877 | { | 927 | { |
878 | if (wait && sb->s_fs_info) | 928 | struct gfs2_sbd *sdp = sb->s_fs_info; |
879 | gfs2_log_flush(sb->s_fs_info, NULL); | 929 | if (wait && sdp) |
930 | gfs2_log_flush(sdp, NULL); | ||
880 | return 0; | 931 | return 0; |
881 | } | 932 | } |
882 | 933 | ||
@@ -1129,9 +1180,7 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) | |||
1129 | 1180 | ||
1130 | /* Some flags must not be changed */ | 1181 | /* Some flags must not be changed */ |
1131 | if (args_neq(&args, &sdp->sd_args, spectator) || | 1182 | if (args_neq(&args, &sdp->sd_args, spectator) || |
1132 | args_neq(&args, &sdp->sd_args, ignore_local_fs) || | ||
1133 | args_neq(&args, &sdp->sd_args, localflocks) || | 1183 | args_neq(&args, &sdp->sd_args, localflocks) || |
1134 | args_neq(&args, &sdp->sd_args, localcaching) || | ||
1135 | args_neq(&args, &sdp->sd_args, meta)) | 1184 | args_neq(&args, &sdp->sd_args, meta)) |
1136 | return -EINVAL; | 1185 | return -EINVAL; |
1137 | 1186 | ||
@@ -1234,16 +1283,10 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) | |||
1234 | seq_printf(s, ",hostdata=%s", args->ar_hostdata); | 1283 | seq_printf(s, ",hostdata=%s", args->ar_hostdata); |
1235 | if (args->ar_spectator) | 1284 | if (args->ar_spectator) |
1236 | seq_printf(s, ",spectator"); | 1285 | seq_printf(s, ",spectator"); |
1237 | if (args->ar_ignore_local_fs) | ||
1238 | seq_printf(s, ",ignore_local_fs"); | ||
1239 | if (args->ar_localflocks) | 1286 | if (args->ar_localflocks) |
1240 | seq_printf(s, ",localflocks"); | 1287 | seq_printf(s, ",localflocks"); |
1241 | if (args->ar_localcaching) | ||
1242 | seq_printf(s, ",localcaching"); | ||
1243 | if (args->ar_debug) | 1288 | if (args->ar_debug) |
1244 | seq_printf(s, ",debug"); | 1289 | seq_printf(s, ",debug"); |
1245 | if (args->ar_upgrade) | ||
1246 | seq_printf(s, ",upgrade"); | ||
1247 | if (args->ar_posix_acl) | 1290 | if (args->ar_posix_acl) |
1248 | seq_printf(s, ",acl"); | 1291 | seq_printf(s, ",acl"); |
1249 | if (args->ar_quota != GFS2_QUOTA_DEFAULT) { | 1292 | if (args->ar_quota != GFS2_QUOTA_DEFAULT) { |
@@ -1317,7 +1360,92 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) | |||
1317 | return 0; | 1360 | return 0; |
1318 | } | 1361 | } |
1319 | 1362 | ||
1320 | /* | 1363 | static void gfs2_final_release_pages(struct gfs2_inode *ip) |
1364 | { | ||
1365 | struct inode *inode = &ip->i_inode; | ||
1366 | struct gfs2_glock *gl = ip->i_gl; | ||
1367 | |||
1368 | truncate_inode_pages(gfs2_glock2aspace(ip->i_gl), 0); | ||
1369 | truncate_inode_pages(&inode->i_data, 0); | ||
1370 | |||
1371 | if (atomic_read(&gl->gl_revokes) == 0) { | ||
1372 | clear_bit(GLF_LFLUSH, &gl->gl_flags); | ||
1373 | clear_bit(GLF_DIRTY, &gl->gl_flags); | ||
1374 | } | ||
1375 | } | ||
1376 | |||
1377 | static int gfs2_dinode_dealloc(struct gfs2_inode *ip) | ||
1378 | { | ||
1379 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | ||
1380 | struct gfs2_alloc *al; | ||
1381 | struct gfs2_rgrpd *rgd; | ||
1382 | int error; | ||
1383 | |||
1384 | if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { | ||
1385 | gfs2_consist_inode(ip); | ||
1386 | return -EIO; | ||
1387 | } | ||
1388 | |||
1389 | al = gfs2_alloc_get(ip); | ||
1390 | if (!al) | ||
1391 | return -ENOMEM; | ||
1392 | |||
1393 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | ||
1394 | if (error) | ||
1395 | goto out; | ||
1396 | |||
1397 | error = gfs2_rindex_hold(sdp, &al->al_ri_gh); | ||
1398 | if (error) | ||
1399 | goto out_qs; | ||
1400 | |||
1401 | rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); | ||
1402 | if (!rgd) { | ||
1403 | gfs2_consist_inode(ip); | ||
1404 | error = -EIO; | ||
1405 | goto out_rindex_relse; | ||
1406 | } | ||
1407 | |||
1408 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, | ||
1409 | &al->al_rgd_gh); | ||
1410 | if (error) | ||
1411 | goto out_rindex_relse; | ||
1412 | |||
1413 | error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, | ||
1414 | sdp->sd_jdesc->jd_blocks); | ||
1415 | if (error) | ||
1416 | goto out_rg_gunlock; | ||
1417 | |||
1418 | gfs2_free_di(rgd, ip); | ||
1419 | |||
1420 | gfs2_final_release_pages(ip); | ||
1421 | |||
1422 | gfs2_trans_end(sdp); | ||
1423 | |||
1424 | out_rg_gunlock: | ||
1425 | gfs2_glock_dq_uninit(&al->al_rgd_gh); | ||
1426 | out_rindex_relse: | ||
1427 | gfs2_glock_dq_uninit(&al->al_ri_gh); | ||
1428 | out_qs: | ||
1429 | gfs2_quota_unhold(ip); | ||
1430 | out: | ||
1431 | gfs2_alloc_put(ip); | ||
1432 | return error; | ||
1433 | } | ||
1434 | |||
1435 | /** | ||
1436 | * gfs2_evict_inode - Remove an inode from cache | ||
1437 | * @inode: The inode to evict | ||
1438 | * | ||
1439 | * There are three cases to consider: | ||
1440 | * 1. i_nlink == 0, we are final opener (and must deallocate) | ||
1441 | * 2. i_nlink == 0, we are not the final opener (and cannot deallocate) | ||
1442 | * 3. i_nlink > 0 | ||
1443 | * | ||
1444 | * If the fs is read only, then we have to treat all cases as per #3 | ||
1445 | * since we are unable to do any deallocation. The inode will be | ||
1446 | * deallocated by the next read/write node to attempt an allocation | ||
1447 | * in the same resource group | ||
1448 | * | ||
1321 | * We have to (at the moment) hold the inodes main lock to cover | 1449 | * We have to (at the moment) hold the inodes main lock to cover |
1322 | * the gap between unlocking the shared lock on the iopen lock and | 1450 | * the gap between unlocking the shared lock on the iopen lock and |
1323 | * taking the exclusive lock. I'd rather do a shared -> exclusive | 1451 | * taking the exclusive lock. I'd rather do a shared -> exclusive |
@@ -1327,15 +1455,17 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) | |||
1327 | 1455 | ||
1328 | static void gfs2_evict_inode(struct inode *inode) | 1456 | static void gfs2_evict_inode(struct inode *inode) |
1329 | { | 1457 | { |
1330 | struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; | 1458 | struct super_block *sb = inode->i_sb; |
1459 | struct gfs2_sbd *sdp = sb->s_fs_info; | ||
1331 | struct gfs2_inode *ip = GFS2_I(inode); | 1460 | struct gfs2_inode *ip = GFS2_I(inode); |
1332 | struct gfs2_holder gh; | 1461 | struct gfs2_holder gh; |
1333 | int error; | 1462 | int error; |
1334 | 1463 | ||
1335 | if (inode->i_nlink) | 1464 | if (inode->i_nlink || (sb->s_flags & MS_RDONLY)) |
1336 | goto out; | 1465 | goto out; |
1337 | 1466 | ||
1338 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | 1467 | /* Must not read inode block until block type has been verified */ |
1468 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh); | ||
1339 | if (unlikely(error)) { | 1469 | if (unlikely(error)) { |
1340 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); | 1470 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); |
1341 | goto out; | 1471 | goto out; |
@@ -1345,12 +1475,21 @@ static void gfs2_evict_inode(struct inode *inode) | |||
1345 | if (error) | 1475 | if (error) |
1346 | goto out_truncate; | 1476 | goto out_truncate; |
1347 | 1477 | ||
1478 | if (test_bit(GIF_INVALID, &ip->i_flags)) { | ||
1479 | error = gfs2_inode_refresh(ip); | ||
1480 | if (error) | ||
1481 | goto out_truncate; | ||
1482 | } | ||
1483 | |||
1484 | ip->i_iopen_gh.gh_flags |= GL_NOCACHE; | ||
1348 | gfs2_glock_dq_wait(&ip->i_iopen_gh); | 1485 | gfs2_glock_dq_wait(&ip->i_iopen_gh); |
1349 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); | 1486 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); |
1350 | error = gfs2_glock_nq(&ip->i_iopen_gh); | 1487 | error = gfs2_glock_nq(&ip->i_iopen_gh); |
1351 | if (error) | 1488 | if (error) |
1352 | goto out_truncate; | 1489 | goto out_truncate; |
1353 | 1490 | ||
1491 | /* Case 1 starts here */ | ||
1492 | |||
1354 | if (S_ISDIR(inode->i_mode) && | 1493 | if (S_ISDIR(inode->i_mode) && |
1355 | (ip->i_diskflags & GFS2_DIF_EXHASH)) { | 1494 | (ip->i_diskflags & GFS2_DIF_EXHASH)) { |
1356 | error = gfs2_dir_exhash_dealloc(ip); | 1495 | error = gfs2_dir_exhash_dealloc(ip); |
@@ -1371,10 +1510,10 @@ static void gfs2_evict_inode(struct inode *inode) | |||
1371 | } | 1510 | } |
1372 | 1511 | ||
1373 | error = gfs2_dinode_dealloc(ip); | 1512 | error = gfs2_dinode_dealloc(ip); |
1374 | if (error) | 1513 | goto out_unlock; |
1375 | goto out_unlock; | ||
1376 | 1514 | ||
1377 | out_truncate: | 1515 | out_truncate: |
1516 | /* Case 2 starts here */ | ||
1378 | error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); | 1517 | error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); |
1379 | if (error) | 1518 | if (error) |
1380 | goto out_unlock; | 1519 | goto out_unlock; |
@@ -1383,6 +1522,7 @@ out_truncate: | |||
1383 | gfs2_trans_end(sdp); | 1522 | gfs2_trans_end(sdp); |
1384 | 1523 | ||
1385 | out_unlock: | 1524 | out_unlock: |
1525 | /* Error path for case 1 */ | ||
1386 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) | 1526 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) |
1387 | gfs2_glock_dq(&ip->i_iopen_gh); | 1527 | gfs2_glock_dq(&ip->i_iopen_gh); |
1388 | gfs2_holder_uninit(&ip->i_iopen_gh); | 1528 | gfs2_holder_uninit(&ip->i_iopen_gh); |
@@ -1390,10 +1530,12 @@ out_unlock: | |||
1390 | if (error && error != GLR_TRYFAILED && error != -EROFS) | 1530 | if (error && error != GLR_TRYFAILED && error != -EROFS) |
1391 | fs_warn(sdp, "gfs2_evict_inode: %d\n", error); | 1531 | fs_warn(sdp, "gfs2_evict_inode: %d\n", error); |
1392 | out: | 1532 | out: |
1533 | /* Case 3 starts here */ | ||
1393 | truncate_inode_pages(&inode->i_data, 0); | 1534 | truncate_inode_pages(&inode->i_data, 0); |
1394 | end_writeback(inode); | 1535 | end_writeback(inode); |
1395 | 1536 | ||
1396 | ip->i_gl->gl_object = NULL; | 1537 | ip->i_gl->gl_object = NULL; |
1538 | gfs2_glock_add_to_lru(ip->i_gl); | ||
1397 | gfs2_glock_put(ip->i_gl); | 1539 | gfs2_glock_put(ip->i_gl); |
1398 | ip->i_gl = NULL; | 1540 | ip->i_gl = NULL; |
1399 | if (ip->i_iopen_gh.gh_gl) { | 1541 | if (ip->i_iopen_gh.gh_gl) { |
@@ -1414,11 +1556,18 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb) | |||
1414 | return &ip->i_inode; | 1556 | return &ip->i_inode; |
1415 | } | 1557 | } |
1416 | 1558 | ||
1417 | static void gfs2_destroy_inode(struct inode *inode) | 1559 | static void gfs2_i_callback(struct rcu_head *head) |
1418 | { | 1560 | { |
1561 | struct inode *inode = container_of(head, struct inode, i_rcu); | ||
1562 | INIT_LIST_HEAD(&inode->i_dentry); | ||
1419 | kmem_cache_free(gfs2_inode_cachep, inode); | 1563 | kmem_cache_free(gfs2_inode_cachep, inode); |
1420 | } | 1564 | } |
1421 | 1565 | ||
1566 | static void gfs2_destroy_inode(struct inode *inode) | ||
1567 | { | ||
1568 | call_rcu(&inode->i_rcu, gfs2_i_callback); | ||
1569 | } | ||
1570 | |||
1422 | const struct super_operations gfs2_super_ops = { | 1571 | const struct super_operations gfs2_super_ops = { |
1423 | .alloc_inode = gfs2_alloc_inode, | 1572 | .alloc_inode = gfs2_alloc_inode, |
1424 | .destroy_inode = gfs2_destroy_inode, | 1573 | .destroy_inode = gfs2_destroy_inode, |