Commit f7545144 authored by Ryusuke Konishi's avatar Ryusuke Konishi

nilfs2: use sb instance instead of nilfs_sb_info struct

This replaces sbi uses with direct reference to sb instance.
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent d96bbfa2
...@@ -295,11 +295,11 @@ extern int nilfs_check_feature_compatibility(struct super_block *, ...@@ -295,11 +295,11 @@ extern int nilfs_check_feature_compatibility(struct super_block *,
struct nilfs_super_block *); struct nilfs_super_block *);
extern void nilfs_set_log_cursor(struct nilfs_super_block *, extern void nilfs_set_log_cursor(struct nilfs_super_block *,
struct the_nilfs *); struct the_nilfs *);
extern struct nilfs_super_block **nilfs_prepare_super(struct nilfs_sb_info *, struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb,
int flip); int flip);
extern int nilfs_commit_super(struct nilfs_sb_info *, int); int nilfs_commit_super(struct super_block *sb, int flag);
extern int nilfs_cleanup_super(struct nilfs_sb_info *); int nilfs_cleanup_super(struct super_block *sb);
int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt, int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt,
struct nilfs_root **root); struct nilfs_root **root);
int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno); int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno);
......
...@@ -425,7 +425,7 @@ void nilfs_dispose_segment_list(struct list_head *head) ...@@ -425,7 +425,7 @@ void nilfs_dispose_segment_list(struct list_head *head)
} }
static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
struct nilfs_sb_info *sbi, struct super_block *sb,
struct nilfs_recovery_info *ri) struct nilfs_recovery_info *ri)
{ {
struct list_head *head = &ri->ri_used_segments; struct list_head *head = &ri->ri_used_segments;
...@@ -501,7 +501,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs, ...@@ -501,7 +501,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
} }
static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
struct nilfs_sb_info *sbi, struct super_block *sb,
struct nilfs_root *root, struct nilfs_root *root,
struct list_head *head, struct list_head *head,
unsigned long *nr_salvaged_blocks) unsigned long *nr_salvaged_blocks)
...@@ -514,7 +514,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, ...@@ -514,7 +514,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
int err = 0, err2 = 0; int err = 0, err2 = 0;
list_for_each_entry_safe(rb, n, head, list) { list_for_each_entry_safe(rb, n, head, list) {
inode = nilfs_iget(sbi->s_super, root, rb->ino); inode = nilfs_iget(sb, root, rb->ino);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
inode = NULL; inode = NULL;
...@@ -572,11 +572,11 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, ...@@ -572,11 +572,11 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
* nilfs_do_roll_forward - salvage logical segments newer than the latest * nilfs_do_roll_forward - salvage logical segments newer than the latest
* checkpoint * checkpoint
* @nilfs: nilfs object * @nilfs: nilfs object
* @sbi: nilfs_sb_info * @sb: super block instance
* @ri: pointer to a nilfs_recovery_info * @ri: pointer to a nilfs_recovery_info
*/ */
static int nilfs_do_roll_forward(struct the_nilfs *nilfs, static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
struct nilfs_sb_info *sbi, struct super_block *sb,
struct nilfs_root *root, struct nilfs_root *root,
struct nilfs_recovery_info *ri) struct nilfs_recovery_info *ri)
{ {
...@@ -648,7 +648,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, ...@@ -648,7 +648,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
goto failed; goto failed;
if (flags & NILFS_SS_LOGEND) { if (flags & NILFS_SS_LOGEND) {
err = nilfs_recover_dsync_blocks( err = nilfs_recover_dsync_blocks(
nilfs, sbi, root, &dsync_blocks, nilfs, sb, root, &dsync_blocks,
&nsalvaged_blocks); &nsalvaged_blocks);
if (unlikely(err)) if (unlikely(err))
goto failed; goto failed;
...@@ -681,7 +681,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, ...@@ -681,7 +681,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
if (nsalvaged_blocks) { if (nsalvaged_blocks) {
printk(KERN_INFO "NILFS (device %s): salvaged %lu blocks\n", printk(KERN_INFO "NILFS (device %s): salvaged %lu blocks\n",
sbi->s_super->s_id, nsalvaged_blocks); sb->s_id, nsalvaged_blocks);
ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE; ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE;
} }
out: out:
...@@ -695,7 +695,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, ...@@ -695,7 +695,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
printk(KERN_ERR printk(KERN_ERR
"NILFS (device %s): Error roll-forwarding " "NILFS (device %s): Error roll-forwarding "
"(err=%d, pseg block=%llu). ", "(err=%d, pseg block=%llu). ",
sbi->s_super->s_id, err, (unsigned long long)pseg_start); sb->s_id, err, (unsigned long long)pseg_start);
goto out; goto out;
} }
...@@ -724,7 +724,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, ...@@ -724,7 +724,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
/** /**
* nilfs_salvage_orphan_logs - salvage logs written after the latest checkpoint * nilfs_salvage_orphan_logs - salvage logs written after the latest checkpoint
* @nilfs: nilfs object * @nilfs: nilfs object
* @sbi: nilfs_sb_info * @sb: super block instance
* @ri: pointer to a nilfs_recovery_info struct to store search results. * @ri: pointer to a nilfs_recovery_info struct to store search results.
* *
* Return Value: On success, 0 is returned. On error, one of the following * Return Value: On success, 0 is returned. On error, one of the following
...@@ -741,7 +741,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, ...@@ -741,7 +741,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
* %-ENOMEM - Insufficient memory available. * %-ENOMEM - Insufficient memory available.
*/ */
int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
struct nilfs_sb_info *sbi, struct super_block *sb,
struct nilfs_recovery_info *ri) struct nilfs_recovery_info *ri)
{ {
struct nilfs_root *root; struct nilfs_root *root;
...@@ -750,32 +750,32 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, ...@@ -750,32 +750,32 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
if (ri->ri_lsegs_start == 0 || ri->ri_lsegs_end == 0) if (ri->ri_lsegs_start == 0 || ri->ri_lsegs_end == 0)
return 0; return 0;
err = nilfs_attach_checkpoint(sbi, ri->ri_cno, true, &root); err = nilfs_attach_checkpoint(sb, ri->ri_cno, true, &root);
if (unlikely(err)) { if (unlikely(err)) {
printk(KERN_ERR printk(KERN_ERR
"NILFS: error loading the latest checkpoint.\n"); "NILFS: error loading the latest checkpoint.\n");
return err; return err;
} }
err = nilfs_do_roll_forward(nilfs, sbi, root, ri); err = nilfs_do_roll_forward(nilfs, sb, root, ri);
if (unlikely(err)) if (unlikely(err))
goto failed; goto failed;
if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) {
err = nilfs_prepare_segment_for_recovery(nilfs, sbi, ri); err = nilfs_prepare_segment_for_recovery(nilfs, sb, ri);
if (unlikely(err)) { if (unlikely(err)) {
printk(KERN_ERR "NILFS: Error preparing segments for " printk(KERN_ERR "NILFS: Error preparing segments for "
"recovery.\n"); "recovery.\n");
goto failed; goto failed;
} }
err = nilfs_attach_segment_constructor(sbi, root); err = nilfs_attach_log_writer(sb, root);
if (unlikely(err)) if (unlikely(err))
goto failed; goto failed;
set_nilfs_discontinued(nilfs); set_nilfs_discontinued(nilfs);
err = nilfs_construct_segment(sbi->s_super); err = nilfs_construct_segment(sb);
nilfs_detach_segment_constructor(sbi); nilfs_detach_log_writer(sb);
if (unlikely(err)) { if (unlikely(err)) {
printk(KERN_ERR "NILFS: Oops! recovery failed. " printk(KERN_ERR "NILFS: Oops! recovery failed. "
......
...@@ -181,7 +181,6 @@ int nilfs_transaction_begin(struct super_block *sb, ...@@ -181,7 +181,6 @@ int nilfs_transaction_begin(struct super_block *sb,
struct nilfs_transaction_info *ti, struct nilfs_transaction_info *ti,
int vacancy_check) int vacancy_check)
{ {
struct nilfs_sb_info *sbi;
struct the_nilfs *nilfs; struct the_nilfs *nilfs;
int ret = nilfs_prepare_segment_lock(ti); int ret = nilfs_prepare_segment_lock(ti);
...@@ -192,8 +191,7 @@ int nilfs_transaction_begin(struct super_block *sb, ...@@ -192,8 +191,7 @@ int nilfs_transaction_begin(struct super_block *sb,
vfs_check_frozen(sb, SB_FREEZE_WRITE); vfs_check_frozen(sb, SB_FREEZE_WRITE);
sbi = NILFS_SB(sb); nilfs = NILFS_SB(sb)->s_nilfs;
nilfs = sbi->s_nilfs;
down_read(&nilfs->ns_segctor_sem); down_read(&nilfs->ns_segctor_sem);
if (vacancy_check && nilfs_near_disk_full(nilfs)) { if (vacancy_check && nilfs_near_disk_full(nilfs)) {
up_read(&nilfs->ns_segctor_sem); up_read(&nilfs->ns_segctor_sem);
...@@ -290,12 +288,12 @@ void nilfs_relax_pressure_in_lock(struct super_block *sb) ...@@ -290,12 +288,12 @@ void nilfs_relax_pressure_in_lock(struct super_block *sb)
downgrade_write(&nilfs->ns_segctor_sem); downgrade_write(&nilfs->ns_segctor_sem);
} }
static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, static void nilfs_transaction_lock(struct super_block *sb,
struct nilfs_transaction_info *ti, struct nilfs_transaction_info *ti,
int gcflag) int gcflag)
{ {
struct nilfs_transaction_info *cur_ti = current->journal_info; struct nilfs_transaction_info *cur_ti = current->journal_info;
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
struct nilfs_sc_info *sci = nilfs->ns_writer; struct nilfs_sc_info *sci = nilfs->ns_writer;
WARN_ON(cur_ti); WARN_ON(cur_ti);
...@@ -313,17 +311,17 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, ...@@ -313,17 +311,17 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi,
nilfs_segctor_do_immediate_flush(sci); nilfs_segctor_do_immediate_flush(sci);
up_write(&sbi->s_nilfs->ns_segctor_sem); up_write(&nilfs->ns_segctor_sem);
yield(); yield();
} }
if (gcflag) if (gcflag)
ti->ti_flags |= NILFS_TI_GC; ti->ti_flags |= NILFS_TI_GC;
} }
static void nilfs_transaction_unlock(struct nilfs_sb_info *sbi) static void nilfs_transaction_unlock(struct super_block *sb)
{ {
struct nilfs_transaction_info *ti = current->journal_info; struct nilfs_transaction_info *ti = current->journal_info;
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC);
BUG_ON(ti->ti_count > 0); BUG_ON(ti->ti_count > 0);
...@@ -2292,8 +2290,7 @@ int nilfs_construct_segment(struct super_block *sb) ...@@ -2292,8 +2290,7 @@ int nilfs_construct_segment(struct super_block *sb)
int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
loff_t start, loff_t end) loff_t start, loff_t end)
{ {
struct nilfs_sb_info *sbi = NILFS_SB(sb); struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
struct the_nilfs *nilfs = sbi->s_nilfs;
struct nilfs_sc_info *sci = nilfs->ns_writer; struct nilfs_sc_info *sci = nilfs->ns_writer;
struct nilfs_inode_info *ii; struct nilfs_inode_info *ii;
struct nilfs_transaction_info ti; struct nilfs_transaction_info ti;
...@@ -2302,14 +2299,14 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, ...@@ -2302,14 +2299,14 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
if (!sci) if (!sci)
return -EROFS; return -EROFS;
nilfs_transaction_lock(sbi, &ti, 0); nilfs_transaction_lock(sb, &ti, 0);
ii = NILFS_I(inode); ii = NILFS_I(inode);
if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) ||
nilfs_test_opt(nilfs, STRICT_ORDER) || nilfs_test_opt(nilfs, STRICT_ORDER) ||
test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) ||
nilfs_discontinued(nilfs)) { nilfs_discontinued(nilfs)) {
nilfs_transaction_unlock(sbi); nilfs_transaction_unlock(sb);
err = nilfs_segctor_sync(sci); err = nilfs_segctor_sync(sci);
return err; return err;
} }
...@@ -2318,7 +2315,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, ...@@ -2318,7 +2315,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && if (!test_bit(NILFS_I_QUEUED, &ii->i_state) &&
!test_bit(NILFS_I_BUSY, &ii->i_state)) { !test_bit(NILFS_I_BUSY, &ii->i_state)) {
spin_unlock(&nilfs->ns_inode_lock); spin_unlock(&nilfs->ns_inode_lock);
nilfs_transaction_unlock(sbi); nilfs_transaction_unlock(sb);
return 0; return 0;
} }
spin_unlock(&nilfs->ns_inode_lock); spin_unlock(&nilfs->ns_inode_lock);
...@@ -2328,7 +2325,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, ...@@ -2328,7 +2325,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC);
nilfs_transaction_unlock(sbi); nilfs_transaction_unlock(sb);
return err; return err;
} }
...@@ -2384,8 +2381,7 @@ static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err) ...@@ -2384,8 +2381,7 @@ static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err)
*/ */
static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode)
{ {
struct nilfs_sb_info *sbi = NILFS_SB(sci->sc_super); struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs;
struct the_nilfs *nilfs = sbi->s_nilfs;
struct nilfs_super_block **sbp; struct nilfs_super_block **sbp;
int err = 0; int err = 0;
...@@ -2403,11 +2399,12 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) ...@@ -2403,11 +2399,12 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode)
nilfs_discontinued(nilfs)) { nilfs_discontinued(nilfs)) {
down_write(&nilfs->ns_sem); down_write(&nilfs->ns_sem);
err = -EIO; err = -EIO;
sbp = nilfs_prepare_super(sbi, sbp = nilfs_prepare_super(sci->sc_super,
nilfs_sb_will_flip(nilfs)); nilfs_sb_will_flip(nilfs));
if (likely(sbp)) { if (likely(sbp)) {
nilfs_set_log_cursor(sbp[0], nilfs); nilfs_set_log_cursor(sbp[0], nilfs);
err = nilfs_commit_super(sbi, NILFS_SB_COMMIT); err = nilfs_commit_super(sci->sc_super,
NILFS_SB_COMMIT);
} }
up_write(&nilfs->ns_sem); up_write(&nilfs->ns_sem);
} }
...@@ -2439,8 +2436,7 @@ nilfs_remove_written_gcinodes(struct the_nilfs *nilfs, struct list_head *head) ...@@ -2439,8 +2436,7 @@ nilfs_remove_written_gcinodes(struct the_nilfs *nilfs, struct list_head *head)
int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
void **kbufs) void **kbufs)
{ {
struct nilfs_sb_info *sbi = NILFS_SB(sb); struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
struct the_nilfs *nilfs = sbi->s_nilfs;
struct nilfs_sc_info *sci = nilfs->ns_writer; struct nilfs_sc_info *sci = nilfs->ns_writer;
struct nilfs_transaction_info ti; struct nilfs_transaction_info ti;
int err; int err;
...@@ -2448,7 +2444,7 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, ...@@ -2448,7 +2444,7 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
if (unlikely(!sci)) if (unlikely(!sci))
return -EROFS; return -EROFS;
nilfs_transaction_lock(sbi, &ti, 1); nilfs_transaction_lock(sb, &ti, 1);
err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat); err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat);
if (unlikely(err)) if (unlikely(err))
...@@ -2491,16 +2487,15 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, ...@@ -2491,16 +2487,15 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
sci->sc_freesegs = NULL; sci->sc_freesegs = NULL;
sci->sc_nfreesegs = 0; sci->sc_nfreesegs = 0;
nilfs_mdt_clear_shadow_map(nilfs->ns_dat); nilfs_mdt_clear_shadow_map(nilfs->ns_dat);
nilfs_transaction_unlock(sbi); nilfs_transaction_unlock(sb);
return err; return err;
} }
static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode)
{ {
struct nilfs_sb_info *sbi = NILFS_SB(sci->sc_super);
struct nilfs_transaction_info ti; struct nilfs_transaction_info ti;
nilfs_transaction_lock(sbi, &ti, 0); nilfs_transaction_lock(sci->sc_super, &ti, 0);
nilfs_segctor_construct(sci, mode); nilfs_segctor_construct(sci, mode);
/* /*
...@@ -2511,7 +2506,7 @@ static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) ...@@ -2511,7 +2506,7 @@ static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode)
if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags))
nilfs_segctor_start_timer(sci); nilfs_segctor_start_timer(sci);
nilfs_transaction_unlock(sbi); nilfs_transaction_unlock(sci->sc_super);
} }
static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci) static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci)
...@@ -2668,17 +2663,17 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci) ...@@ -2668,17 +2663,17 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci)
/* /*
* Setup & clean-up functions * Setup & clean-up functions
*/ */
static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi, static struct nilfs_sc_info *nilfs_segctor_new(struct super_block *sb,
struct nilfs_root *root) struct nilfs_root *root)
{ {
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
struct nilfs_sc_info *sci; struct nilfs_sc_info *sci;
sci = kzalloc(sizeof(*sci), GFP_KERNEL); sci = kzalloc(sizeof(*sci), GFP_KERNEL);
if (!sci) if (!sci)
return NULL; return NULL;
sci->sc_super = sbi->s_super; sci->sc_super = sb;
nilfs_get_root(root); nilfs_get_root(root);
sci->sc_root = root; sci->sc_root = root;
...@@ -2712,12 +2707,11 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) ...@@ -2712,12 +2707,11 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci)
/* The segctord thread was stopped and its timer was removed. /* The segctord thread was stopped and its timer was removed.
But some tasks remain. */ But some tasks remain. */
do { do {
struct nilfs_sb_info *sbi = NILFS_SB(sci->sc_super);
struct nilfs_transaction_info ti; struct nilfs_transaction_info ti;
nilfs_transaction_lock(sbi, &ti, 0); nilfs_transaction_lock(sci->sc_super, &ti, 0);
ret = nilfs_segctor_construct(sci, SC_LSEG_SR); ret = nilfs_segctor_construct(sci, SC_LSEG_SR);
nilfs_transaction_unlock(sbi); nilfs_transaction_unlock(sci->sc_super);
} while (ret && retrycount-- > 0); } while (ret && retrycount-- > 0);
} }
...@@ -2766,22 +2760,21 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) ...@@ -2766,22 +2760,21 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci)
} }
/** /**
* nilfs_attach_segment_constructor - attach a segment constructor * nilfs_attach_log_writer - attach log writer
* @sbi: nilfs_sb_info * @sb: super block instance
* @root: root object of the current filesystem tree * @root: root object of the current filesystem tree
* *
* nilfs_attach_segment_constructor() allocates a struct nilfs_sc_info, * This allocates a log writer object, initializes it, and starts the
* initializes it, and starts the segment constructor. * log writer.
* *
* Return Value: On success, 0 is returned. On error, one of the following * Return Value: On success, 0 is returned. On error, one of the following
* negative error code is returned. * negative error code is returned.
* *
* %-ENOMEM - Insufficient memory available. * %-ENOMEM - Insufficient memory available.
*/ */
int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root)
struct nilfs_root *root)
{ {
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
int err; int err;
if (nilfs->ns_writer) { if (nilfs->ns_writer) {
...@@ -2790,10 +2783,10 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, ...@@ -2790,10 +2783,10 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi,
* read/write after nilfs_error degenerated it into a * read/write after nilfs_error degenerated it into a
* read-only mount. * read-only mount.
*/ */
nilfs_detach_segment_constructor(sbi); nilfs_detach_log_writer(sb);
} }
nilfs->ns_writer = nilfs_segctor_new(sbi, root); nilfs->ns_writer = nilfs_segctor_new(sb, root);
if (!nilfs->ns_writer) if (!nilfs->ns_writer)
return -ENOMEM; return -ENOMEM;
...@@ -2806,15 +2799,15 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, ...@@ -2806,15 +2799,15 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi,
} }
/** /**
* nilfs_detach_segment_constructor - destroy the segment constructor * nilfs_detach_log_writer - destroy log writer
* @sbi: nilfs_sb_info * @sb: super block instance
* *
* nilfs_detach_segment_constructor() kills the segment constructor daemon, * This kills log writer daemon, frees the log writer object, and
* frees the struct nilfs_sc_info, and destroy the dirty file list. * destroys list of dirty files.
*/ */
void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) void nilfs_detach_log_writer(struct super_block *sb)
{ {
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
LIST_HEAD(garbage_list); LIST_HEAD(garbage_list);
down_write(&nilfs->ns_segctor_sem); down_write(&nilfs->ns_segctor_sem);
...@@ -2827,9 +2820,8 @@ void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) ...@@ -2827,9 +2820,8 @@ void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi)
spin_lock(&nilfs->ns_inode_lock); spin_lock(&nilfs->ns_inode_lock);
if (!list_empty(&nilfs->ns_dirty_files)) { if (!list_empty(&nilfs->ns_dirty_files)) {
list_splice_init(&nilfs->ns_dirty_files, &garbage_list); list_splice_init(&nilfs->ns_dirty_files, &garbage_list);
nilfs_warning(sbi->s_super, __func__, nilfs_warning(sb, __func__,
"Non empty dirty list after the last " "Hit dirty file after stopped log writer\n");
"segment construction\n");
} }
spin_unlock(&nilfs->ns_inode_lock); spin_unlock(&nilfs->ns_inode_lock);
up_write(&nilfs->ns_segctor_sem); up_write(&nilfs->ns_segctor_sem);
......
...@@ -233,18 +233,16 @@ extern void nilfs_flush_segment(struct super_block *, ino_t); ...@@ -233,18 +233,16 @@ extern void nilfs_flush_segment(struct super_block *, ino_t);
extern int nilfs_clean_segments(struct super_block *, struct nilfs_argv *, extern int nilfs_clean_segments(struct super_block *, struct nilfs_argv *,
void **); void **);
int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root);
struct nilfs_root *root); void nilfs_detach_log_writer(struct super_block *sb);
extern void nilfs_detach_segment_constructor(struct nilfs_sb_info *);
/* recovery.c */ /* recovery.c */
extern int nilfs_read_super_root_block(struct the_nilfs *, sector_t, extern int nilfs_read_super_root_block(struct the_nilfs *, sector_t,
struct buffer_head **, int); struct buffer_head **, int);
extern int nilfs_search_super_root(struct the_nilfs *, extern int nilfs_search_super_root(struct the_nilfs *,
struct nilfs_recovery_info *); struct nilfs_recovery_info *);
extern int nilfs_salvage_orphan_logs(struct the_nilfs *, int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
struct nilfs_sb_info *, struct nilfs_recovery_info *ri);
struct nilfs_recovery_info *);
extern void nilfs_dispose_segment_list(struct list_head *); extern void nilfs_dispose_segment_list(struct list_head *);
#endif /* _NILFS_SEGMENT_H */ #endif /* _NILFS_SEGMENT_H */
This diff is collapsed.
...@@ -201,16 +201,16 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs, ...@@ -201,16 +201,16 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs,
/** /**
* load_nilfs - load and recover the nilfs * load_nilfs - load and recover the nilfs
* @nilfs: the_nilfs structure to be released * @nilfs: the_nilfs structure to be released
* @sbi: nilfs_sb_info used to recover past segment * @sb: super block isntance used to recover past segment
* *
* load_nilfs() searches and load the latest super root, * load_nilfs() searches and load the latest super root,
* attaches the last segment, and does recovery if needed. * attaches the last segment, and does recovery if needed.
* The caller must call this exclusively for simultaneous mounts. * The caller must call this exclusively for simultaneous mounts.
*/ */
int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
{ {
struct nilfs_recovery_info ri; struct nilfs_recovery_info ri;
unsigned int s_flags = sbi->s_super->s_flags; unsigned int s_flags = sb->s_flags;
int really_read_only = bdev_read_only(nilfs->ns_bdev); int really_read_only = bdev_read_only(nilfs->ns_bdev);
int valid_fs = nilfs_valid_fs(nilfs); int valid_fs = nilfs_valid_fs(nilfs);
int err; int err;
...@@ -275,7 +275,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) ...@@ -275,7 +275,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
goto scan_error; goto scan_error;
} }
err = nilfs_load_super_root(nilfs, sbi->s_super, ri.ri_super_root); err = nilfs_load_super_root(nilfs, sb, ri.ri_super_root);
if (unlikely(err)) { if (unlikely(err)) {
printk(KERN_ERR "NILFS: error loading super root.\n"); printk(KERN_ERR "NILFS: error loading super root.\n");
goto failed; goto failed;
...@@ -308,7 +308,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) ...@@ -308,7 +308,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
err = -EROFS; err = -EROFS;
goto failed_unload; goto failed_unload;
} }
sbi->s_super->s_flags &= ~MS_RDONLY; sb->s_flags &= ~MS_RDONLY;
} else if (nilfs_test_opt(nilfs, NORECOVERY)) { } else if (nilfs_test_opt(nilfs, NORECOVERY)) {
printk(KERN_ERR "NILFS: recovery cancelled because norecovery " printk(KERN_ERR "NILFS: recovery cancelled because norecovery "
"option was specified for a read/write mount\n"); "option was specified for a read/write mount\n");
...@@ -316,13 +316,13 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) ...@@ -316,13 +316,13 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
goto failed_unload; goto failed_unload;
} }
err = nilfs_salvage_orphan_logs(nilfs, sbi, &ri); err = nilfs_salvage_orphan_logs(nilfs, sb, &ri);
if (err) if (err)
goto failed_unload; goto failed_unload;
down_write(&nilfs->ns_sem); down_write(&nilfs->ns_sem);
nilfs->ns_mount_state |= NILFS_VALID_FS; /* set "clean" flag */ nilfs->ns_mount_state |= NILFS_VALID_FS; /* set "clean" flag */
err = nilfs_cleanup_super(sbi); err = nilfs_cleanup_super(sb);
up_write(&nilfs->ns_sem); up_write(&nilfs->ns_sem);
if (err) { if (err) {
...@@ -334,7 +334,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) ...@@ -334,7 +334,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
skip_recovery: skip_recovery:
nilfs_clear_recovery_info(&ri); nilfs_clear_recovery_info(&ri);
sbi->s_super->s_flags = s_flags; sb->s_flags = s_flags;
return 0; return 0;
scan_error: scan_error:
...@@ -348,7 +348,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) ...@@ -348,7 +348,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
failed: failed:
nilfs_clear_recovery_info(&ri); nilfs_clear_recovery_info(&ri);
sbi->s_super->s_flags = s_flags; sb->s_flags = s_flags;
return err; return err;
} }
...@@ -526,7 +526,6 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, ...@@ -526,7 +526,6 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,
/** /**
* init_nilfs - initialize a NILFS instance. * init_nilfs - initialize a NILFS instance.
* @nilfs: the_nilfs structure * @nilfs: the_nilfs structure
* @sbi: nilfs_sb_info
* @sb: super block * @sb: super block
* @data: mount options * @data: mount options
* *
...@@ -537,9 +536,8 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, ...@@ -537,9 +536,8 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,
* Return Value: On success, 0 is returned. On error, a negative error * Return Value: On success, 0 is returned. On error, a negative error
* code is returned. * code is returned.
*/ */
int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)
{ {
struct super_block *sb = sbi->s_super;
struct nilfs_super_block *sbp; struct nilfs_super_block *sbp;
int blocksize; int blocksize;
int err; int err;
......
...@@ -267,15 +267,14 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs) ...@@ -267,15 +267,14 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs)
void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
struct the_nilfs *alloc_nilfs(struct block_device *bdev); struct the_nilfs *alloc_nilfs(struct block_device *bdev);
void destroy_nilfs(struct the_nilfs *nilfs); void destroy_nilfs(struct the_nilfs *nilfs);
int init_nilfs(struct the_nilfs *, struct nilfs_sb_info *, char *); int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data);
int load_nilfs(struct the_nilfs *, struct nilfs_sb_info *); int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb);
int nilfs_discard_segments(struct the_nilfs *, __u64 *, size_t); int nilfs_discard_segments(struct the_nilfs *, __u64 *, size_t);
int nilfs_count_free_blocks(struct the_nilfs *, sector_t *); int nilfs_count_free_blocks(struct the_nilfs *, sector_t *);
struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno); struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno);
struct nilfs_root *nilfs_find_or_create_root(struct the_nilfs *nilfs, struct nilfs_root *nilfs_find_or_create_root(struct the_nilfs *nilfs,
__u64 cno); __u64 cno);
void nilfs_put_root(struct nilfs_root *root); void nilfs_put_root(struct nilfs_root *root);
struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *, int, __u64);
int nilfs_near_disk_full(struct the_nilfs *); int nilfs_near_disk_full(struct the_nilfs *);
void nilfs_fall_back_super_block(struct the_nilfs *); void nilfs_fall_back_super_block(struct the_nilfs *);
void nilfs_swap_super_block(struct the_nilfs *); void nilfs_swap_super_block(struct the_nilfs *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment