diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-18 20:07:08 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-06 17:39:48 -0400 |
commit | 163073db51930d1f9c2960b8e5660c269164f29b (patch) | |
tree | 83b98778cea4a37dd189387518993e57fda412ee /fs/ufs | |
parent | 7b4e4f7f815db0059150a12542b28c787e19c0d7 (diff) |
free_full_branch(): saner calling conventions
Have caller fetch the block number *and* remove it from wherever
it was. Pass the block number instead.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r-- | fs/ufs/inode.c | 100 |
1 files changed, 51 insertions, 49 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 314caad56d83..efe71e5acb00 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -1070,57 +1070,48 @@ next1: | |||
1070 | UFSD("EXIT: ino %lu\n", inode->i_ino); | 1070 | UFSD("EXIT: ino %lu\n", inode->i_ino); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static void free_full_branch(struct inode *inode, int depth, void *p) | 1073 | static void free_full_branch(struct inode *inode, u64 ind_block, int depth) |
1074 | { | 1074 | { |
1075 | struct super_block *sb = inode->i_sb; | 1075 | struct super_block *sb = inode->i_sb; |
1076 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; | 1076 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
1077 | struct ufs_inode_info *ufsi = UFS_I(inode); | 1077 | struct ufs_buffer_head *ubh = ubh_bread(sb, ind_block, uspi->s_bsize); |
1078 | struct ufs_buffer_head *ubh; | ||
1079 | u64 tmp; | ||
1080 | unsigned i; | 1078 | unsigned i; |
1081 | 1079 | ||
1082 | tmp = ufs_data_ptr_to_cpu(sb, p); | 1080 | if (!ubh) |
1083 | if (!tmp) | ||
1084 | return; | ||
1085 | ubh = ubh_bread (sb, tmp, uspi->s_bsize); | ||
1086 | if (!ubh) { | ||
1087 | write_seqlock(&ufsi->meta_lock); | ||
1088 | ufs_data_ptr_clear(uspi, p); | ||
1089 | write_sequnlock(&ufsi->meta_lock); | ||
1090 | return; | 1081 | return; |
1091 | } | ||
1092 | 1082 | ||
1093 | if (--depth) { | 1083 | if (--depth) { |
1094 | for (i = 0 ; i < uspi->s_apb ; i++) { | 1084 | for (i = 0; i < uspi->s_apb; i++) { |
1095 | void *ind = ubh_get_data_ptr(uspi, ubh, i); | 1085 | void *p = ubh_get_data_ptr(uspi, ubh, i); |
1096 | free_full_branch(inode, depth, ind); | 1086 | u64 block = ufs_data_ptr_to_cpu(sb, p); |
1097 | ubh_mark_buffer_dirty(ubh); | 1087 | if (block) { |
1088 | write_seqlock(&UFS_I(inode)->meta_lock); | ||
1089 | ufs_data_ptr_clear(uspi, p); | ||
1090 | write_sequnlock(&UFS_I(inode)->meta_lock); | ||
1091 | free_full_branch(inode, block, depth); | ||
1092 | ubh_mark_buffer_dirty(ubh); | ||
1093 | } | ||
1098 | } | 1094 | } |
1099 | } else { | 1095 | } else { |
1100 | struct to_free ctx = {.inode = inode}; | 1096 | struct to_free ctx = {.inode = inode}; |
1101 | 1097 | ||
1102 | for (i = 0; i < uspi->s_apb; i++) { | 1098 | for (i = 0; i < uspi->s_apb; i++) { |
1103 | void *ind = ubh_get_data_ptr(uspi, ubh, i); | 1099 | void *p = ubh_get_data_ptr(uspi, ubh, i); |
1104 | tmp = ufs_data_ptr_to_cpu(sb, ind); | 1100 | u64 block = ufs_data_ptr_to_cpu(sb, p); |
1105 | if (!tmp) | 1101 | if (block) { |
1106 | continue; | 1102 | write_seqlock(&UFS_I(inode)->meta_lock); |
1107 | 1103 | ufs_data_ptr_clear(uspi, p); | |
1108 | write_seqlock(&UFS_I(inode)->meta_lock); | 1104 | write_sequnlock(&UFS_I(inode)->meta_lock); |
1109 | ufs_data_ptr_clear(uspi, ind); | 1105 | ubh_mark_buffer_dirty(ubh); |
1110 | write_sequnlock(&UFS_I(inode)->meta_lock); | 1106 | free_data(&ctx, block, uspi->s_fpb); |
1111 | ubh_mark_buffer_dirty(ubh); | 1107 | mark_inode_dirty(inode); |
1112 | free_data(&ctx, tmp, uspi->s_fpb); | 1108 | } |
1113 | mark_inode_dirty(inode); | ||
1114 | } | 1109 | } |
1115 | free_data(&ctx, 0, 0); | 1110 | free_data(&ctx, 0, 0); |
1116 | } | 1111 | } |
1117 | tmp = ufs_data_ptr_to_cpu(sb, p); | ||
1118 | write_seqlock(&ufsi->meta_lock); | ||
1119 | ufs_data_ptr_clear(uspi, p); | ||
1120 | write_sequnlock(&ufsi->meta_lock); | ||
1121 | 1112 | ||
1122 | ubh_bforget(ubh); | 1113 | ubh_bforget(ubh); |
1123 | ufs_free_blocks(inode, tmp, uspi->s_fpb); | 1114 | ufs_free_blocks(inode, ind_block, uspi->s_fpb); |
1124 | mark_inode_dirty(inode); | 1115 | mark_inode_dirty(inode); |
1125 | } | 1116 | } |
1126 | 1117 | ||
@@ -1132,25 +1123,30 @@ static void free_branch_tail(struct inode *inode, unsigned from, struct ufs_buff | |||
1132 | 1123 | ||
1133 | if (--depth) { | 1124 | if (--depth) { |
1134 | for (i = from; i < uspi->s_apb ; i++) { | 1125 | for (i = from; i < uspi->s_apb ; i++) { |
1135 | void *ind = ubh_get_data_ptr(uspi, ubh, i); | 1126 | void *p = ubh_get_data_ptr(uspi, ubh, i); |
1136 | free_full_branch(inode, depth, ind); | 1127 | u64 block = ufs_data_ptr_to_cpu(sb, p); |
1137 | ubh_mark_buffer_dirty(ubh); | 1128 | if (block) { |
1129 | write_seqlock(&UFS_I(inode)->meta_lock); | ||
1130 | ufs_data_ptr_clear(uspi, p); | ||
1131 | write_sequnlock(&UFS_I(inode)->meta_lock); | ||
1132 | ubh_mark_buffer_dirty(ubh); | ||
1133 | free_full_branch(inode, block, depth); | ||
1134 | } | ||
1138 | } | 1135 | } |
1139 | } else { | 1136 | } else { |
1140 | struct to_free ctx = {.inode = inode}; | 1137 | struct to_free ctx = {.inode = inode}; |
1141 | 1138 | ||
1142 | for (i = from; i < uspi->s_apb; i++) { | 1139 | for (i = from; i < uspi->s_apb; i++) { |
1143 | void *ind = ubh_get_data_ptr(uspi, ubh, i); | 1140 | void *p = ubh_get_data_ptr(uspi, ubh, i); |
1144 | u64 tmp = ufs_data_ptr_to_cpu(sb, ind); | 1141 | u64 block = ufs_data_ptr_to_cpu(sb, p); |
1145 | if (!tmp) | 1142 | if (block) { |
1146 | continue; | 1143 | write_seqlock(&UFS_I(inode)->meta_lock); |
1147 | 1144 | ufs_data_ptr_clear(uspi, p); | |
1148 | write_seqlock(&UFS_I(inode)->meta_lock); | 1145 | write_sequnlock(&UFS_I(inode)->meta_lock); |
1149 | ufs_data_ptr_clear(uspi, ind); | 1146 | ubh_mark_buffer_dirty(ubh); |
1150 | write_sequnlock(&UFS_I(inode)->meta_lock); | 1147 | free_data(&ctx, block, uspi->s_fpb); |
1151 | ubh_mark_buffer_dirty(ubh); | 1148 | mark_inode_dirty(inode); |
1152 | free_data(&ctx, tmp, uspi->s_fpb); | 1149 | } |
1153 | mark_inode_dirty(inode); | ||
1154 | } | 1150 | } |
1155 | free_data(&ctx, 0, 0); | 1151 | free_data(&ctx, 0, 0); |
1156 | } | 1152 | } |
@@ -1277,8 +1273,14 @@ static void __ufs_truncate_blocks(struct inode *inode) | |||
1277 | } | 1273 | } |
1278 | } | 1274 | } |
1279 | for (i = offsets[0]; i <= UFS_TIND_BLOCK; i++) { | 1275 | for (i = offsets[0]; i <= UFS_TIND_BLOCK; i++) { |
1280 | free_full_branch(inode, i - UFS_IND_BLOCK + 1, | 1276 | p = ufs_get_direct_data_ptr(uspi, ufsi, i); |
1281 | ufs_get_direct_data_ptr(uspi, ufsi, i)); | 1277 | block = ufs_data_ptr_to_cpu(sb, p); |
1278 | if (block) { | ||
1279 | write_seqlock(&ufsi->meta_lock); | ||
1280 | ufs_data_ptr_clear(uspi, p); | ||
1281 | write_sequnlock(&ufsi->meta_lock); | ||
1282 | free_full_branch(inode, block, i - UFS_IND_BLOCK + 1); | ||
1283 | } | ||
1282 | } | 1284 | } |
1283 | ufsi->i_lastfrag = DIRECT_FRAGMENT; | 1285 | ufsi->i_lastfrag = DIRECT_FRAGMENT; |
1284 | mutex_unlock(&ufsi->truncate_mutex); | 1286 | mutex_unlock(&ufsi->truncate_mutex); |