Skip to content

Commit 654137d

Browse files
committed
nilfs2: remove header file for segment list operations
This will eliminate obsolete list operations of nilfs_segment_entry structure which has been used to handle mutiple segment numbers. The patch ("nilfs2: remove list of freeing segments") removed use of the structure from the segment constructor code, and this patch simplifies the remaining code by integrating it into recovery.c. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
1 parent 071cb4b commit 654137d

4 files changed

Lines changed: 25 additions & 93 deletions

File tree

‎fs/nilfs2/recovery.c‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "segment.h"
2929
#include "sufile.h"
3030
#include "page.h"
31-
#include "seglist.h"
3231
#include "segbuf.h"
3332

3433
/*
@@ -395,14 +394,32 @@ static void dispose_recovery_list(struct list_head *head)
395394
}
396395
}
397396

397+
struct nilfs_segment_entry {
398+
struct list_head list;
399+
__u64 segnum;
400+
};
401+
402+
static int nilfs_segment_list_add(struct list_head *head, __u64 segnum)
403+
{
404+
struct nilfs_segment_entry *ent = kmalloc(sizeof(*ent), GFP_NOFS);
405+
406+
if (unlikely(!ent))
407+
return -ENOMEM;
408+
409+
ent->segnum = segnum;
410+
INIT_LIST_HEAD(&ent->list);
411+
list_add_tail(&ent->list, head);
412+
return 0;
413+
}
414+
398415
void nilfs_dispose_segment_list(struct list_head *head)
399416
{
400417
while (!list_empty(head)) {
401418
struct nilfs_segment_entry *ent
402419
= list_entry(head->next,
403420
struct nilfs_segment_entry, list);
404421
list_del(&ent->list);
405-
nilfs_free_segment_entry(ent);
422+
kfree(ent);
406423
}
407424
}
408425

@@ -431,12 +448,10 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
431448
if (unlikely(err))
432449
goto failed;
433450

434-
err = -ENOMEM;
435451
for (i = 1; i < 4; i++) {
436-
ent = nilfs_alloc_segment_entry(segnum[i]);
437-
if (unlikely(!ent))
452+
err = nilfs_segment_list_add(head, segnum[i]);
453+
if (unlikely(err))
438454
goto failed;
439-
list_add_tail(&ent->list, head);
440455
}
441456

442457
/*
@@ -450,7 +465,7 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
450465
goto failed;
451466
}
452467
list_del(&ent->list);
453-
nilfs_free_segment_entry(ent);
468+
kfree(ent);
454469
}
455470

456471
/* Allocate new segments for recovery */
@@ -791,7 +806,6 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
791806
u64 seg_seq;
792807
__u64 segnum, nextnum = 0;
793808
__u64 cno;
794-
struct nilfs_segment_entry *ent;
795809
LIST_HEAD(segments);
796810
int empty_seg = 0, scan_newer = 0;
797811
int ret;
@@ -892,12 +906,9 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
892906
if (empty_seg++)
893907
goto super_root_found; /* found a valid super root */
894908

895-
ent = nilfs_alloc_segment_entry(segnum);
896-
if (unlikely(!ent)) {
897-
ret = -ENOMEM;
909+
ret = nilfs_segment_list_add(&segments, segnum);
910+
if (unlikely(ret))
898911
goto failed;
899-
}
900-
list_add_tail(&ent->list, &segments);
901912

902913
seg_seq++;
903914
segnum = nextnum;

‎fs/nilfs2/seglist.h‎

Lines changed: 0 additions & 79 deletions
This file was deleted.

‎fs/nilfs2/segment.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,6 @@ extern int nilfs_search_super_root(struct the_nilfs *, struct nilfs_sb_info *,
239239
extern int nilfs_recover_logical_segments(struct the_nilfs *,
240240
struct nilfs_sb_info *,
241241
struct nilfs_recovery_info *);
242+
extern void nilfs_dispose_segment_list(struct list_head *);
242243

243244
#endif /* _NILFS_SEGMENT_H */

‎fs/nilfs2/the_nilfs.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "cpfile.h"
3333
#include "sufile.h"
3434
#include "dat.h"
35-
#include "seglist.h"
3635
#include "segbuf.h"
3736

3837
void nilfs_set_last_segment(struct the_nilfs *nilfs,

0 commit comments

Comments
 (0)