.. | .. |
---|
921 | 921 | struct nilfs_transaction_info ti; |
---|
922 | 922 | struct super_block *sb = inode->i_sb; |
---|
923 | 923 | struct nilfs_inode_info *ii = NILFS_I(inode); |
---|
| 924 | + struct the_nilfs *nilfs; |
---|
924 | 925 | int ret; |
---|
925 | 926 | |
---|
926 | 927 | if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) { |
---|
.. | .. |
---|
932 | 933 | nilfs_transaction_begin(sb, &ti, 0); /* never fails */ |
---|
933 | 934 | |
---|
934 | 935 | truncate_inode_pages_final(&inode->i_data); |
---|
| 936 | + |
---|
| 937 | + nilfs = sb->s_fs_info; |
---|
| 938 | + if (unlikely(sb_rdonly(sb) || !nilfs->ns_writer)) { |
---|
| 939 | + /* |
---|
| 940 | + * If this inode is about to be disposed after the file system |
---|
| 941 | + * has been degraded to read-only due to file system corruption |
---|
| 942 | + * or after the writer has been detached, do not make any |
---|
| 943 | + * changes that cause writes, just clear it. |
---|
| 944 | + * Do this check after read-locking ns_segctor_sem by |
---|
| 945 | + * nilfs_transaction_begin() in order to avoid a race with |
---|
| 946 | + * the writer detach operation. |
---|
| 947 | + */ |
---|
| 948 | + clear_inode(inode); |
---|
| 949 | + nilfs_clear_inode(inode); |
---|
| 950 | + nilfs_transaction_abort(sb); |
---|
| 951 | + return; |
---|
| 952 | + } |
---|
935 | 953 | |
---|
936 | 954 | /* TODO: some of the following operations may fail. */ |
---|
937 | 955 | nilfs_truncate_bmap(ii, 0); |
---|
.. | .. |
---|
1009 | 1027 | int err; |
---|
1010 | 1028 | |
---|
1011 | 1029 | spin_lock(&nilfs->ns_inode_lock); |
---|
1012 | | - if (ii->i_bh == NULL) { |
---|
| 1030 | + if (ii->i_bh == NULL || unlikely(!buffer_uptodate(ii->i_bh))) { |
---|
1013 | 1031 | spin_unlock(&nilfs->ns_inode_lock); |
---|
1014 | 1032 | err = nilfs_ifile_get_inode_block(ii->i_root->ifile, |
---|
1015 | 1033 | inode->i_ino, pbh); |
---|
.. | .. |
---|
1018 | 1036 | spin_lock(&nilfs->ns_inode_lock); |
---|
1019 | 1037 | if (ii->i_bh == NULL) |
---|
1020 | 1038 | ii->i_bh = *pbh; |
---|
1021 | | - else { |
---|
| 1039 | + else if (unlikely(!buffer_uptodate(ii->i_bh))) { |
---|
| 1040 | + __brelse(ii->i_bh); |
---|
| 1041 | + ii->i_bh = *pbh; |
---|
| 1042 | + } else { |
---|
1022 | 1043 | brelse(*pbh); |
---|
1023 | 1044 | *pbh = ii->i_bh; |
---|
1024 | 1045 | } |
---|
.. | .. |
---|
1085 | 1106 | |
---|
1086 | 1107 | int __nilfs_mark_inode_dirty(struct inode *inode, int flags) |
---|
1087 | 1108 | { |
---|
| 1109 | + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
---|
1088 | 1110 | struct buffer_head *ibh; |
---|
1089 | 1111 | int err; |
---|
1090 | 1112 | |
---|
| 1113 | + /* |
---|
| 1114 | + * Do not dirty inodes after the log writer has been detached |
---|
| 1115 | + * and its nilfs_root struct has been freed. |
---|
| 1116 | + */ |
---|
| 1117 | + if (unlikely(nilfs_purging(nilfs))) |
---|
| 1118 | + return 0; |
---|
| 1119 | + |
---|
1091 | 1120 | err = nilfs_load_inode_block(inode, &ibh); |
---|
1092 | 1121 | if (unlikely(err)) { |
---|
1093 | 1122 | nilfs_warn(inode->i_sb, |
---|