Skip to content

Commit ef2fb67

Browse files
Eric SandeenLinus Torvalds
authored andcommitted
remove unused bh in calls to ext234_get_group_desc
ext[234]_get_group_desc never tests the bh argument, and only sets it if it is passed in; it is perfectly happy with a NULL bh argument. But, many callers send one in and never use it. May as well call with NULL like other callers who don't use the bh. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Cc: <linux-ext4@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 74bf17c commit ef2fb67

4 files changed

Lines changed: 23 additions & 37 deletions

File tree

‎fs/ext2/ialloc.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ static void ext2_preread_inode(struct inode *inode)
177177
unsigned long block_group;
178178
unsigned long offset;
179179
unsigned long block;
180-
struct buffer_head *bh;
181180
struct ext2_group_desc * gdp;
182181
struct backing_dev_info *bdi;
183182

@@ -188,7 +187,7 @@ static void ext2_preread_inode(struct inode *inode)
188187
return;
189188

190189
block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb);
191-
gdp = ext2_get_group_desc(inode->i_sb, block_group, &bh);
190+
gdp = ext2_get_group_desc(inode->i_sb, block_group, NULL);
192191
if (gdp == NULL)
193192
return;
194193

@@ -217,11 +216,10 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
217216
int ngroups = EXT2_SB(sb)->s_groups_count;
218217
int avefreei = ext2_count_free_inodes(sb) / ngroups;
219218
struct ext2_group_desc *desc, *best_desc = NULL;
220-
struct buffer_head *bh, *best_bh = NULL;
221219
int group, best_group = -1;
222220

223221
for (group = 0; group < ngroups; group++) {
224-
desc = ext2_get_group_desc (sb, group, &bh);
222+
desc = ext2_get_group_desc (sb, group, NULL);
225223
if (!desc || !desc->bg_free_inodes_count)
226224
continue;
227225
if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
@@ -231,7 +229,6 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
231229
le16_to_cpu(best_desc->bg_free_blocks_count))) {
232230
best_group = group;
233231
best_desc = desc;
234-
best_bh = bh;
235232
}
236233
}
237234
if (!best_desc)
@@ -284,7 +281,6 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
284281
int max_debt, max_dirs, min_blocks, min_inodes;
285282
int group = -1, i;
286283
struct ext2_group_desc *desc;
287-
struct buffer_head *bh;
288284

289285
freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
290286
avefreei = freei / ngroups;
@@ -295,15 +291,14 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
295291
if ((parent == sb->s_root->d_inode) ||
296292
(EXT2_I(parent)->i_flags & EXT2_TOPDIR_FL)) {
297293
struct ext2_group_desc *best_desc = NULL;
298-
struct buffer_head *best_bh = NULL;
299294
int best_ndir = inodes_per_group;
300295
int best_group = -1;
301296

302297
get_random_bytes(&group, sizeof(group));
303298
parent_group = (unsigned)group % ngroups;
304299
for (i = 0; i < ngroups; i++) {
305300
group = (parent_group + i) % ngroups;
306-
desc = ext2_get_group_desc (sb, group, &bh);
301+
desc = ext2_get_group_desc (sb, group, NULL);
307302
if (!desc || !desc->bg_free_inodes_count)
308303
continue;
309304
if (le16_to_cpu(desc->bg_used_dirs_count) >= best_ndir)
@@ -315,11 +310,9 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
315310
best_group = group;
316311
best_ndir = le16_to_cpu(desc->bg_used_dirs_count);
317312
best_desc = desc;
318-
best_bh = bh;
319313
}
320314
if (best_group >= 0) {
321315
desc = best_desc;
322-
bh = best_bh;
323316
group = best_group;
324317
goto found;
325318
}
@@ -345,7 +338,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
345338

346339
for (i = 0; i < ngroups; i++) {
347340
group = (parent_group + i) % ngroups;
348-
desc = ext2_get_group_desc (sb, group, &bh);
341+
desc = ext2_get_group_desc (sb, group, NULL);
349342
if (!desc || !desc->bg_free_inodes_count)
350343
continue;
351344
if (sbi->s_debts[group] >= max_debt)
@@ -362,7 +355,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
362355
fallback:
363356
for (i = 0; i < ngroups; i++) {
364357
group = (parent_group + i) % ngroups;
365-
desc = ext2_get_group_desc (sb, group, &bh);
358+
desc = ext2_get_group_desc (sb, group, NULL);
366359
if (!desc || !desc->bg_free_inodes_count)
367360
continue;
368361
if (le16_to_cpu(desc->bg_free_inodes_count) >= avefreei)
@@ -389,14 +382,13 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
389382
int parent_group = EXT2_I(parent)->i_block_group;
390383
int ngroups = EXT2_SB(sb)->s_groups_count;
391384
struct ext2_group_desc *desc;
392-
struct buffer_head *bh;
393385
int group, i;
394386

395387
/*
396388
* Try to place the inode in its parent directory
397389
*/
398390
group = parent_group;
399-
desc = ext2_get_group_desc (sb, group, &bh);
391+
desc = ext2_get_group_desc (sb, group, NULL);
400392
if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
401393
le16_to_cpu(desc->bg_free_blocks_count))
402394
goto found;
@@ -420,7 +412,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
420412
group += i;
421413
if (group >= ngroups)
422414
group -= ngroups;
423-
desc = ext2_get_group_desc (sb, group, &bh);
415+
desc = ext2_get_group_desc (sb, group, NULL);
424416
if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
425417
le16_to_cpu(desc->bg_free_blocks_count))
426418
goto found;
@@ -434,7 +426,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
434426
for (i = 0; i < ngroups; i++) {
435427
if (++group >= ngroups)
436428
group = 0;
437-
desc = ext2_get_group_desc (sb, group, &bh);
429+
desc = ext2_get_group_desc (sb, group, NULL);
438430
if (desc && le16_to_cpu(desc->bg_free_inodes_count))
439431
goto found;
440432
}

‎fs/ext2/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ static struct ext2_inode *ext2_get_inode(struct super_block *sb, ino_t ino,
10281028
goto Einval;
10291029

10301030
block_group = (ino - 1) / EXT2_INODES_PER_GROUP(sb);
1031-
gdp = ext2_get_group_desc(sb, block_group, &bh);
1031+
gdp = ext2_get_group_desc(sb, block_group, NULL);
10321032
if (!gdp)
10331033
goto Egdp;
10341034
/*

‎fs/ext3/ialloc.c‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,13 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
204204
int ngroups = EXT3_SB(sb)->s_groups_count;
205205
unsigned int freei, avefreei;
206206
struct ext3_group_desc *desc, *best_desc = NULL;
207-
struct buffer_head *bh;
208207
int group, best_group = -1;
209208

210209
freei = percpu_counter_read_positive(&EXT3_SB(sb)->s_freeinodes_counter);
211210
avefreei = freei / ngroups;
212211

213212
for (group = 0; group < ngroups; group++) {
214-
desc = ext3_get_group_desc (sb, group, &bh);
213+
desc = ext3_get_group_desc (sb, group, NULL);
215214
if (!desc || !desc->bg_free_inodes_count)
216215
continue;
217216
if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
@@ -269,7 +268,6 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
269268
ext3_grpblk_t min_blocks;
270269
int group = -1, i;
271270
struct ext3_group_desc *desc;
272-
struct buffer_head *bh;
273271

274272
freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
275273
avefreei = freei / ngroups;
@@ -286,7 +284,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
286284
parent_group = (unsigned)group % ngroups;
287285
for (i = 0; i < ngroups; i++) {
288286
group = (parent_group + i) % ngroups;
289-
desc = ext3_get_group_desc (sb, group, &bh);
287+
desc = ext3_get_group_desc (sb, group, NULL);
290288
if (!desc || !desc->bg_free_inodes_count)
291289
continue;
292290
if (le16_to_cpu(desc->bg_used_dirs_count) >= best_ndir)
@@ -319,7 +317,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
319317

320318
for (i = 0; i < ngroups; i++) {
321319
group = (parent_group + i) % ngroups;
322-
desc = ext3_get_group_desc (sb, group, &bh);
320+
desc = ext3_get_group_desc (sb, group, NULL);
323321
if (!desc || !desc->bg_free_inodes_count)
324322
continue;
325323
if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
@@ -334,7 +332,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
334332
fallback:
335333
for (i = 0; i < ngroups; i++) {
336334
group = (parent_group + i) % ngroups;
337-
desc = ext3_get_group_desc (sb, group, &bh);
335+
desc = ext3_get_group_desc (sb, group, NULL);
338336
if (!desc || !desc->bg_free_inodes_count)
339337
continue;
340338
if (le16_to_cpu(desc->bg_free_inodes_count) >= avefreei)
@@ -358,14 +356,13 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
358356
int parent_group = EXT3_I(parent)->i_block_group;
359357
int ngroups = EXT3_SB(sb)->s_groups_count;
360358
struct ext3_group_desc *desc;
361-
struct buffer_head *bh;
362359
int group, i;
363360

364361
/*
365362
* Try to place the inode in its parent directory
366363
*/
367364
group = parent_group;
368-
desc = ext3_get_group_desc (sb, group, &bh);
365+
desc = ext3_get_group_desc (sb, group, NULL);
369366
if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
370367
le16_to_cpu(desc->bg_free_blocks_count))
371368
return group;
@@ -389,7 +386,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
389386
group += i;
390387
if (group >= ngroups)
391388
group -= ngroups;
392-
desc = ext3_get_group_desc (sb, group, &bh);
389+
desc = ext3_get_group_desc (sb, group, NULL);
393390
if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
394391
le16_to_cpu(desc->bg_free_blocks_count))
395392
return group;
@@ -403,7 +400,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
403400
for (i = 0; i < ngroups; i++) {
404401
if (++group >= ngroups)
405402
group = 0;
406-
desc = ext3_get_group_desc (sb, group, &bh);
403+
desc = ext3_get_group_desc (sb, group, NULL);
407404
if (desc && le16_to_cpu(desc->bg_free_inodes_count))
408405
return group;
409406
}

‎fs/ext4/ialloc.c‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,13 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
204204
int ngroups = EXT4_SB(sb)->s_groups_count;
205205
unsigned int freei, avefreei;
206206
struct ext4_group_desc *desc, *best_desc = NULL;
207-
struct buffer_head *bh;
208207
int group, best_group = -1;
209208

210209
freei = percpu_counter_read_positive(&EXT4_SB(sb)->s_freeinodes_counter);
211210
avefreei = freei / ngroups;
212211

213212
for (group = 0; group < ngroups; group++) {
214-
desc = ext4_get_group_desc (sb, group, &bh);
213+
desc = ext4_get_group_desc (sb, group, NULL);
215214
if (!desc || !desc->bg_free_inodes_count)
216215
continue;
217216
if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
@@ -269,7 +268,6 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
269268
ext4_grpblk_t min_blocks;
270269
int group = -1, i;
271270
struct ext4_group_desc *desc;
272-
struct buffer_head *bh;
273271

274272
freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
275273
avefreei = freei / ngroups;
@@ -287,7 +285,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
287285
parent_group = (unsigned)group % ngroups;
288286
for (i = 0; i < ngroups; i++) {
289287
group = (parent_group + i) % ngroups;
290-
desc = ext4_get_group_desc (sb, group, &bh);
288+
desc = ext4_get_group_desc (sb, group, NULL);
291289
if (!desc || !desc->bg_free_inodes_count)
292290
continue;
293291
if (le16_to_cpu(desc->bg_used_dirs_count) >= best_ndir)
@@ -322,7 +320,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
322320

323321
for (i = 0; i < ngroups; i++) {
324322
group = (parent_group + i) % ngroups;
325-
desc = ext4_get_group_desc (sb, group, &bh);
323+
desc = ext4_get_group_desc (sb, group, NULL);
326324
if (!desc || !desc->bg_free_inodes_count)
327325
continue;
328326
if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
@@ -337,7 +335,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
337335
fallback:
338336
for (i = 0; i < ngroups; i++) {
339337
group = (parent_group + i) % ngroups;
340-
desc = ext4_get_group_desc (sb, group, &bh);
338+
desc = ext4_get_group_desc (sb, group, NULL);
341339
if (!desc || !desc->bg_free_inodes_count)
342340
continue;
343341
if (le16_to_cpu(desc->bg_free_inodes_count) >= avefreei)
@@ -361,14 +359,13 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
361359
int parent_group = EXT4_I(parent)->i_block_group;
362360
int ngroups = EXT4_SB(sb)->s_groups_count;
363361
struct ext4_group_desc *desc;
364-
struct buffer_head *bh;
365362
int group, i;
366363

367364
/*
368365
* Try to place the inode in its parent directory
369366
*/
370367
group = parent_group;
371-
desc = ext4_get_group_desc (sb, group, &bh);
368+
desc = ext4_get_group_desc (sb, group, NULL);
372369
if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
373370
le16_to_cpu(desc->bg_free_blocks_count))
374371
return group;
@@ -392,7 +389,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
392389
group += i;
393390
if (group >= ngroups)
394391
group -= ngroups;
395-
desc = ext4_get_group_desc (sb, group, &bh);
392+
desc = ext4_get_group_desc (sb, group, NULL);
396393
if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
397394
le16_to_cpu(desc->bg_free_blocks_count))
398395
return group;
@@ -406,7 +403,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
406403
for (i = 0; i < ngroups; i++) {
407404
if (++group >= ngroups)
408405
group = 0;
409-
desc = ext4_get_group_desc (sb, group, &bh);
406+
desc = ext4_get_group_desc (sb, group, NULL);
410407
if (desc && le16_to_cpu(desc->bg_free_inodes_count))
411408
return group;
412409
}

0 commit comments

Comments
 (0)