Skip to content

Commit

Permalink
nilfs2: remove header file for segment list operations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ryusuke Konishi committed Jun 10, 2009
1 parent 071cb4b commit 654137d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 93 deletions.
37 changes: 24 additions & 13 deletions fs/nilfs2/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "segment.h"
#include "sufile.h"
#include "page.h"
#include "seglist.h"
#include "segbuf.h"

/*
Expand Down Expand Up @@ -395,14 +394,32 @@ static void dispose_recovery_list(struct list_head *head)
}
}

struct nilfs_segment_entry {
struct list_head list;
__u64 segnum;
};

static int nilfs_segment_list_add(struct list_head *head, __u64 segnum)
{
struct nilfs_segment_entry *ent = kmalloc(sizeof(*ent), GFP_NOFS);

if (unlikely(!ent))
return -ENOMEM;

ent->segnum = segnum;
INIT_LIST_HEAD(&ent->list);
list_add_tail(&ent->list, head);
return 0;
}

void nilfs_dispose_segment_list(struct list_head *head)
{
while (!list_empty(head)) {
struct nilfs_segment_entry *ent
= list_entry(head->next,
struct nilfs_segment_entry, list);
list_del(&ent->list);
nilfs_free_segment_entry(ent);
kfree(ent);
}
}

Expand Down Expand Up @@ -431,12 +448,10 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
if (unlikely(err))
goto failed;

err = -ENOMEM;
for (i = 1; i < 4; i++) {
ent = nilfs_alloc_segment_entry(segnum[i]);
if (unlikely(!ent))
err = nilfs_segment_list_add(head, segnum[i]);
if (unlikely(err))
goto failed;
list_add_tail(&ent->list, head);
}

/*
Expand All @@ -450,7 +465,7 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
goto failed;
}
list_del(&ent->list);
nilfs_free_segment_entry(ent);
kfree(ent);
}

/* Allocate new segments for recovery */
Expand Down Expand Up @@ -791,7 +806,6 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
u64 seg_seq;
__u64 segnum, nextnum = 0;
__u64 cno;
struct nilfs_segment_entry *ent;
LIST_HEAD(segments);
int empty_seg = 0, scan_newer = 0;
int ret;
Expand Down Expand Up @@ -892,12 +906,9 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
if (empty_seg++)
goto super_root_found; /* found a valid super root */

ent = nilfs_alloc_segment_entry(segnum);
if (unlikely(!ent)) {
ret = -ENOMEM;
ret = nilfs_segment_list_add(&segments, segnum);
if (unlikely(ret))
goto failed;
}
list_add_tail(&ent->list, &segments);

seg_seq++;
segnum = nextnum;
Expand Down
79 changes: 0 additions & 79 deletions fs/nilfs2/seglist.h

This file was deleted.

1 change: 1 addition & 0 deletions fs/nilfs2/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,6 @@ extern int nilfs_search_super_root(struct the_nilfs *, struct nilfs_sb_info *,
extern int nilfs_recover_logical_segments(struct the_nilfs *,
struct nilfs_sb_info *,
struct nilfs_recovery_info *);
extern void nilfs_dispose_segment_list(struct list_head *);

#endif /* _NILFS_SEGMENT_H */
1 change: 0 additions & 1 deletion fs/nilfs2/the_nilfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "cpfile.h"
#include "sufile.h"
#include "dat.h"
#include "seglist.h"
#include "segbuf.h"

void nilfs_set_last_segment(struct the_nilfs *nilfs,
Expand Down

0 comments on commit 654137d

Please sign in to comment.