Skip to content

Commit 3fd3fe5

Browse files
committed
nilfs2: move log writer onto nilfs object
Log writer is held by the nilfs_sb_info structure. This moves it into nilfs object and replaces all uses of NILFS_SC() accessor. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
1 parent 9b1fc4e commit 3fd3fe5

3 files changed

Lines changed: 34 additions & 39 deletions

File tree

‎fs/nilfs2/sb.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <linux/fs.h>
2929

3030
struct the_nilfs;
31-
struct nilfs_sc_info;
3231

3332
/*
3433
* NILFS super-block data in memory
@@ -37,19 +36,11 @@ struct nilfs_sb_info {
3736
/* Fundamental members */
3837
struct super_block *s_super; /* reverse pointer to super_block */
3938
struct the_nilfs *s_nilfs;
40-
41-
/* Segment constructor */
42-
struct nilfs_sc_info *s_sc_info; /* segment constructor info */
4339
};
4440

4541
static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb)
4642
{
4743
return sb->s_fs_info;
4844
}
4945

50-
static inline struct nilfs_sc_info *NILFS_SC(struct nilfs_sb_info *sbi)
51-
{
52-
return sbi->s_sc_info;
53-
}
54-
5546
#endif /* _NILFS_SB */

‎fs/nilfs2/segment.c‎

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ int nilfs_transaction_begin(struct super_block *sb,
224224
int nilfs_transaction_commit(struct super_block *sb)
225225
{
226226
struct nilfs_transaction_info *ti = current->journal_info;
227-
struct nilfs_sb_info *sbi;
228-
struct nilfs_sc_info *sci;
227+
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
229228
int err = 0;
230229

231230
BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC);
@@ -234,16 +233,15 @@ int nilfs_transaction_commit(struct super_block *sb)
234233
ti->ti_count--;
235234
return 0;
236235
}
237-
sbi = NILFS_SB(sb);
238-
sci = NILFS_SC(sbi);
239-
if (sci != NULL) {
236+
if (nilfs->ns_writer) {
237+
struct nilfs_sc_info *sci = nilfs->ns_writer;
238+
240239
if (ti->ti_flags & NILFS_TI_COMMIT)
241240
nilfs_segctor_start_timer(sci);
242-
if (atomic_read(&sbi->s_nilfs->ns_ndirtyblks) >
243-
sci->sc_watermark)
241+
if (atomic_read(&nilfs->ns_ndirtyblks) > sci->sc_watermark)
244242
nilfs_segctor_do_flush(sci, 0);
245243
}
246-
up_read(&sbi->s_nilfs->ns_segctor_sem);
244+
up_read(&nilfs->ns_segctor_sem);
247245
current->journal_info = ti->ti_save;
248246

249247
if (ti->ti_flags & NILFS_TI_SYNC)
@@ -271,9 +269,8 @@ void nilfs_transaction_abort(struct super_block *sb)
271269

272270
void nilfs_relax_pressure_in_lock(struct super_block *sb)
273271
{
274-
struct nilfs_sb_info *sbi = NILFS_SB(sb);
275-
struct nilfs_sc_info *sci = NILFS_SC(sbi);
276-
struct the_nilfs *nilfs = sbi->s_nilfs;
272+
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
273+
struct nilfs_sc_info *sci = nilfs->ns_writer;
277274

278275
if (!sci || !sci->sc_flush_request)
279276
return;
@@ -298,6 +295,8 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi,
298295
int gcflag)
299296
{
300297
struct nilfs_transaction_info *cur_ti = current->journal_info;
298+
struct the_nilfs *nilfs = sbi->s_nilfs;
299+
struct nilfs_sc_info *sci = nilfs->ns_writer;
301300

302301
WARN_ON(cur_ti);
303302
ti->ti_flags = NILFS_TI_WRITER;
@@ -308,11 +307,11 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi,
308307
current->journal_info = ti;
309308

310309
for (;;) {
311-
down_write(&sbi->s_nilfs->ns_segctor_sem);
312-
if (!test_bit(NILFS_SC_PRIOR_FLUSH, &NILFS_SC(sbi)->sc_flags))
310+
down_write(&nilfs->ns_segctor_sem);
311+
if (!test_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags))
313312
break;
314313

315-
nilfs_segctor_do_immediate_flush(NILFS_SC(sbi));
314+
nilfs_segctor_do_immediate_flush(sci);
316315

317316
up_write(&sbi->s_nilfs->ns_segctor_sem);
318317
yield();
@@ -2169,8 +2168,8 @@ static void nilfs_segctor_do_flush(struct nilfs_sc_info *sci, int bn)
21692168
*/
21702169
void nilfs_flush_segment(struct super_block *sb, ino_t ino)
21712170
{
2172-
struct nilfs_sb_info *sbi = NILFS_SB(sb);
2173-
struct nilfs_sc_info *sci = NILFS_SC(sbi);
2171+
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
2172+
struct nilfs_sc_info *sci = nilfs->ns_writer;
21742173

21752174
if (!sci || nilfs_doing_construction())
21762175
return;
@@ -2259,8 +2258,8 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err)
22592258
*/
22602259
int nilfs_construct_segment(struct super_block *sb)
22612260
{
2262-
struct nilfs_sb_info *sbi = NILFS_SB(sb);
2263-
struct nilfs_sc_info *sci = NILFS_SC(sbi);
2261+
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
2262+
struct nilfs_sc_info *sci = nilfs->ns_writer;
22642263
struct nilfs_transaction_info *ti;
22652264
int err;
22662265

@@ -2299,7 +2298,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
22992298
{
23002299
struct nilfs_sb_info *sbi = NILFS_SB(sb);
23012300
struct the_nilfs *nilfs = sbi->s_nilfs;
2302-
struct nilfs_sc_info *sci = NILFS_SC(sbi);
2301+
struct nilfs_sc_info *sci = nilfs->ns_writer;
23032302
struct nilfs_inode_info *ii;
23042303
struct nilfs_transaction_info ti;
23052304
int err = 0;
@@ -2445,8 +2444,8 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
24452444
void **kbufs)
24462445
{
24472446
struct nilfs_sb_info *sbi = NILFS_SB(sb);
2448-
struct nilfs_sc_info *sci = NILFS_SC(sbi);
24492447
struct the_nilfs *nilfs = sbi->s_nilfs;
2448+
struct nilfs_sc_info *sci = nilfs->ns_writer;
24502449
struct nilfs_transaction_info ti;
24512450
int err;
24522451

@@ -2787,9 +2786,10 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci)
27872786
int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi,
27882787
struct nilfs_root *root)
27892788
{
2789+
struct the_nilfs *nilfs = sbi->s_nilfs;
27902790
int err;
27912791

2792-
if (NILFS_SC(sbi)) {
2792+
if (nilfs->ns_writer) {
27932793
/*
27942794
* This happens if the filesystem was remounted
27952795
* read/write after nilfs_error degenerated it into a
@@ -2798,14 +2798,14 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi,
27982798
nilfs_detach_segment_constructor(sbi);
27992799
}
28002800

2801-
sbi->s_sc_info = nilfs_segctor_new(sbi, root);
2802-
if (!sbi->s_sc_info)
2801+
nilfs->ns_writer = nilfs_segctor_new(sbi, root);
2802+
if (!nilfs->ns_writer)
28032803
return -ENOMEM;
28042804

2805-
err = nilfs_segctor_start_thread(NILFS_SC(sbi));
2805+
err = nilfs_segctor_start_thread(nilfs->ns_writer);
28062806
if (err) {
2807-
kfree(sbi->s_sc_info);
2808-
sbi->s_sc_info = NULL;
2807+
kfree(nilfs->ns_writer);
2808+
nilfs->ns_writer = NULL;
28092809
}
28102810
return err;
28112811
}
@@ -2823,9 +2823,9 @@ void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi)
28232823
LIST_HEAD(garbage_list);
28242824

28252825
down_write(&nilfs->ns_segctor_sem);
2826-
if (NILFS_SC(sbi)) {
2827-
nilfs_segctor_destroy(NILFS_SC(sbi));
2828-
sbi->s_sc_info = NULL;
2826+
if (nilfs->ns_writer) {
2827+
nilfs_segctor_destroy(nilfs->ns_writer);
2828+
nilfs->ns_writer = NULL;
28292829
}
28302830

28312831
/* Force to free the list of dirty files */

‎fs/nilfs2/the_nilfs.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <linux/slab.h>
3434
#include "sb.h"
3535

36+
struct nilfs_sc_info;
37+
3638
/* the_nilfs struct */
3739
enum {
3840
THE_NILFS_INIT = 0, /* Information from super_block is set */
@@ -65,7 +67,8 @@ enum {
6567
* @ns_last_cno: checkpoint number of the latest segment
6668
* @ns_prot_seq: least sequence number of segments which must not be reclaimed
6769
* @ns_prev_seq: base sequence number used to decide if advance log cursor
68-
* @ns_segctor_sem: segment constructor semaphore
70+
* @ns_writer: log writer
71+
* @ns_segctor_sem: semaphore protecting log write
6972
* @ns_dat: DAT file inode
7073
* @ns_cpfile: checkpoint file inode
7174
* @ns_sufile: segusage file inode
@@ -140,6 +143,7 @@ struct the_nilfs {
140143
u64 ns_prot_seq;
141144
u64 ns_prev_seq;
142145

146+
struct nilfs_sc_info *ns_writer;
143147
struct rw_semaphore ns_segctor_sem;
144148

145149
/*

0 commit comments

Comments
 (0)