Skip to content

Commit dcd7618

Browse files
committed
nilfs2: get rid of nilfs_segctor_req struct
This will clean up nilfs_segctor_req struct and the obscure request argument passed among private methods of segment constructor. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
1 parent 086d176 commit dcd7618

2 files changed

Lines changed: 40 additions & 41 deletions

File tree

‎fs/nilfs2/segment.c‎

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,43 +2425,43 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
24252425
return err;
24262426
}
24272427

2428-
struct nilfs_segctor_req {
2429-
int mode;
2430-
__u32 seq_accepted;
2431-
int sc_err; /* construction failure */
2432-
int sb_err; /* super block writeback failure */
2433-
};
2434-
24352428
#define FLUSH_FILE_BIT (0x1) /* data file only */
24362429
#define FLUSH_DAT_BIT (1 << NILFS_DAT_INO) /* DAT only */
24372430

2438-
static void nilfs_segctor_accept(struct nilfs_sc_info *sci,
2439-
struct nilfs_segctor_req *req)
2431+
/**
2432+
* nilfs_segctor_accept - record accepted sequence count of log-write requests
2433+
* @sci: segment constructor object
2434+
*/
2435+
static void nilfs_segctor_accept(struct nilfs_sc_info *sci)
24402436
{
2441-
req->sc_err = req->sb_err = 0;
24422437
spin_lock(&sci->sc_state_lock);
2443-
req->seq_accepted = sci->sc_seq_request;
2438+
sci->sc_seq_accepted = sci->sc_seq_request;
24442439
spin_unlock(&sci->sc_state_lock);
24452440

24462441
if (sci->sc_timer)
24472442
del_timer_sync(sci->sc_timer);
24482443
}
24492444

2450-
static void nilfs_segctor_notify(struct nilfs_sc_info *sci,
2451-
struct nilfs_segctor_req *req)
2445+
/**
2446+
* nilfs_segctor_notify - notify the result of request to caller threads
2447+
* @sci: segment constructor object
2448+
* @mode: mode of log forming
2449+
* @err: error code to be notified
2450+
*/
2451+
static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err)
24522452
{
24532453
/* Clear requests (even when the construction failed) */
24542454
spin_lock(&sci->sc_state_lock);
24552455

2456-
if (req->mode == SC_LSEG_SR) {
2456+
if (mode == SC_LSEG_SR) {
24572457
sci->sc_state &= ~NILFS_SEGCTOR_COMMIT;
2458-
sci->sc_seq_done = req->seq_accepted;
2459-
nilfs_segctor_wakeup(sci, req->sc_err ? : req->sb_err);
2458+
sci->sc_seq_done = sci->sc_seq_accepted;
2459+
nilfs_segctor_wakeup(sci, err);
24602460
sci->sc_flush_request = 0;
24612461
} else {
2462-
if (req->mode == SC_FLUSH_FILE)
2462+
if (mode == SC_FLUSH_FILE)
24632463
sci->sc_flush_request &= ~FLUSH_FILE_BIT;
2464-
else if (req->mode == SC_FLUSH_DAT)
2464+
else if (mode == SC_FLUSH_DAT)
24652465
sci->sc_flush_request &= ~FLUSH_DAT_BIT;
24662466

24672467
/* re-enable timer if checkpoint creation was not done */
@@ -2472,30 +2472,37 @@ static void nilfs_segctor_notify(struct nilfs_sc_info *sci,
24722472
spin_unlock(&sci->sc_state_lock);
24732473
}
24742474

2475-
static int nilfs_segctor_construct(struct nilfs_sc_info *sci,
2476-
struct nilfs_segctor_req *req)
2475+
/**
2476+
* nilfs_segctor_construct - form logs and write them to disk
2477+
* @sci: segment constructor object
2478+
* @mode: mode of log forming
2479+
*/
2480+
static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode)
24772481
{
24782482
struct nilfs_sb_info *sbi = sci->sc_sbi;
24792483
struct the_nilfs *nilfs = sbi->s_nilfs;
24802484
int err = 0;
24812485

2486+
nilfs_segctor_accept(sci);
2487+
24822488
if (nilfs_discontinued(nilfs))
2483-
req->mode = SC_LSEG_SR;
2484-
if (!nilfs_segctor_confirm(sci)) {
2485-
err = nilfs_segctor_do_construct(sci, req->mode);
2486-
req->sc_err = err;
2487-
}
2489+
mode = SC_LSEG_SR;
2490+
if (!nilfs_segctor_confirm(sci))
2491+
err = nilfs_segctor_do_construct(sci, mode);
2492+
24882493
if (likely(!err)) {
2489-
if (req->mode != SC_FLUSH_DAT)
2494+
if (mode != SC_FLUSH_DAT)
24902495
atomic_set(&nilfs->ns_ndirtyblks, 0);
24912496
if (test_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags) &&
24922497
nilfs_discontinued(nilfs)) {
24932498
down_write(&nilfs->ns_sem);
2494-
req->sb_err = nilfs_commit_super(sbi,
2495-
nilfs_altsb_need_update(nilfs));
2499+
err = nilfs_commit_super(
2500+
sbi, nilfs_altsb_need_update(nilfs));
24962501
up_write(&nilfs->ns_sem);
24972502
}
24982503
}
2504+
2505+
nilfs_segctor_notify(sci, mode, err);
24992506
return err;
25002507
}
25012508

@@ -2526,7 +2533,6 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
25262533
struct nilfs_sc_info *sci = NILFS_SC(sbi);
25272534
struct the_nilfs *nilfs = sbi->s_nilfs;
25282535
struct nilfs_transaction_info ti;
2529-
struct nilfs_segctor_req req = { .mode = SC_LSEG_SR };
25302536
int err;
25312537

25322538
if (unlikely(!sci))
@@ -2547,10 +2553,8 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
25472553
list_splice_tail_init(&nilfs->ns_gc_inodes, &sci->sc_gc_inodes);
25482554

25492555
for (;;) {
2550-
nilfs_segctor_accept(sci, &req);
2551-
err = nilfs_segctor_construct(sci, &req);
2556+
err = nilfs_segctor_construct(sci, SC_LSEG_SR);
25522557
nilfs_remove_written_gcinodes(nilfs, &sci->sc_gc_inodes);
2553-
nilfs_segctor_notify(sci, &req);
25542558

25552559
if (likely(!err))
25562560
break;
@@ -2583,13 +2587,9 @@ static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode)
25832587
{
25842588
struct nilfs_sb_info *sbi = sci->sc_sbi;
25852589
struct nilfs_transaction_info ti;
2586-
struct nilfs_segctor_req req = { .mode = mode };
25872590

25882591
nilfs_transaction_lock(sbi, &ti, 0);
2589-
2590-
nilfs_segctor_accept(sci, &req);
2591-
nilfs_segctor_construct(sci, &req);
2592-
nilfs_segctor_notify(sci, &req);
2592+
nilfs_segctor_construct(sci, mode);
25932593

25942594
/*
25952595
* Unclosed segment should be retried. We do this using sc_timer.
@@ -2807,12 +2807,9 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci)
28072807
do {
28082808
struct nilfs_sb_info *sbi = sci->sc_sbi;
28092809
struct nilfs_transaction_info ti;
2810-
struct nilfs_segctor_req req = { .mode = SC_LSEG_SR };
28112810

28122811
nilfs_transaction_lock(sbi, &ti, 0);
2813-
nilfs_segctor_accept(sci, &req);
2814-
ret = nilfs_segctor_construct(sci, &req);
2815-
nilfs_segctor_notify(sci, &req);
2812+
ret = nilfs_segctor_construct(sci, SC_LSEG_SR);
28162813
nilfs_transaction_unlock(sbi);
28172814

28182815
} while (ret && retrycount-- > 0);

‎fs/nilfs2/segment.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct nilfs_segsum_pointer {
116116
* @sc_wait_daemon: Daemon wait queue
117117
* @sc_wait_task: Start/end wait queue to control segctord task
118118
* @sc_seq_request: Request counter
119+
* @sc_seq_accept: Accepted request count
119120
* @sc_seq_done: Completion counter
120121
* @sc_sync: Request of explicit sync operation
121122
* @sc_interval: Timeout value of background construction
@@ -169,6 +170,7 @@ struct nilfs_sc_info {
169170
wait_queue_head_t sc_wait_task;
170171

171172
__u32 sc_seq_request;
173+
__u32 sc_seq_accepted;
172174
__u32 sc_seq_done;
173175

174176
int sc_sync;

0 commit comments

Comments
 (0)