diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2011-03-08 21:05:08 -0500 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2011-03-08 21:05:08 -0500 |
commit | 3fd3fe5aeaa171a5638d2bb54a1a170eab7b7cdc (patch) | |
tree | 3feb95a18e045883b0af27da09be10f5e011776f /fs/nilfs2 | |
parent | 9b1fc4e4973469dd3fab27ba5d78eca1cd5c13fe (diff) |
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>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/sb.h | 9 | ||||
-rw-r--r-- | fs/nilfs2/segment.c | 58 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.h | 6 |
3 files changed, 34 insertions, 39 deletions
diff --git a/fs/nilfs2/sb.h b/fs/nilfs2/sb.h index 6f190dfdc649..44553f42ebac 100644 --- a/fs/nilfs2/sb.h +++ b/fs/nilfs2/sb.h | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | 29 | ||
30 | struct the_nilfs; | 30 | struct the_nilfs; |
31 | struct nilfs_sc_info; | ||
32 | 31 | ||
33 | /* | 32 | /* |
34 | * NILFS super-block data in memory | 33 | * NILFS super-block data in memory |
@@ -37,9 +36,6 @@ struct nilfs_sb_info { | |||
37 | /* Fundamental members */ | 36 | /* Fundamental members */ |
38 | struct super_block *s_super; /* reverse pointer to super_block */ | 37 | struct super_block *s_super; /* reverse pointer to super_block */ |
39 | struct the_nilfs *s_nilfs; | 38 | struct the_nilfs *s_nilfs; |
40 | |||
41 | /* Segment constructor */ | ||
42 | struct nilfs_sc_info *s_sc_info; /* segment constructor info */ | ||
43 | }; | 39 | }; |
44 | 40 | ||
45 | static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) | 41 | static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) |
@@ -47,9 +43,4 @@ static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) | |||
47 | return sb->s_fs_info; | 43 | return sb->s_fs_info; |
48 | } | 44 | } |
49 | 45 | ||
50 | static inline struct nilfs_sc_info *NILFS_SC(struct nilfs_sb_info *sbi) | ||
51 | { | ||
52 | return sbi->s_sc_info; | ||
53 | } | ||
54 | |||
55 | #endif /* _NILFS_SB */ | 46 | #endif /* _NILFS_SB */ |
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 6ac50d811841..e3d1785faf1b 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -224,8 +224,7 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
224 | int nilfs_transaction_commit(struct super_block *sb) | 224 | int nilfs_transaction_commit(struct super_block *sb) |
225 | { | 225 | { |
226 | struct nilfs_transaction_info *ti = current->journal_info; | 226 | struct nilfs_transaction_info *ti = current->journal_info; |
227 | struct nilfs_sb_info *sbi; | 227 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
228 | struct nilfs_sc_info *sci; | ||
229 | int err = 0; | 228 | int err = 0; |
230 | 229 | ||
231 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 230 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
@@ -234,16 +233,15 @@ int nilfs_transaction_commit(struct super_block *sb) | |||
234 | ti->ti_count--; | 233 | ti->ti_count--; |
235 | return 0; | 234 | return 0; |
236 | } | 235 | } |
237 | sbi = NILFS_SB(sb); | 236 | if (nilfs->ns_writer) { |
238 | sci = NILFS_SC(sbi); | 237 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
239 | if (sci != NULL) { | 238 | |
240 | if (ti->ti_flags & NILFS_TI_COMMIT) | 239 | if (ti->ti_flags & NILFS_TI_COMMIT) |
241 | nilfs_segctor_start_timer(sci); | 240 | nilfs_segctor_start_timer(sci); |
242 | if (atomic_read(&sbi->s_nilfs->ns_ndirtyblks) > | 241 | if (atomic_read(&nilfs->ns_ndirtyblks) > sci->sc_watermark) |
243 | sci->sc_watermark) | ||
244 | nilfs_segctor_do_flush(sci, 0); | 242 | nilfs_segctor_do_flush(sci, 0); |
245 | } | 243 | } |
246 | up_read(&sbi->s_nilfs->ns_segctor_sem); | 244 | up_read(&nilfs->ns_segctor_sem); |
247 | current->journal_info = ti->ti_save; | 245 | current->journal_info = ti->ti_save; |
248 | 246 | ||
249 | if (ti->ti_flags & NILFS_TI_SYNC) | 247 | if (ti->ti_flags & NILFS_TI_SYNC) |
@@ -271,9 +269,8 @@ void nilfs_transaction_abort(struct super_block *sb) | |||
271 | 269 | ||
272 | void nilfs_relax_pressure_in_lock(struct super_block *sb) | 270 | void nilfs_relax_pressure_in_lock(struct super_block *sb) |
273 | { | 271 | { |
274 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 272 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
275 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 273 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
276 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
277 | 274 | ||
278 | if (!sci || !sci->sc_flush_request) | 275 | if (!sci || !sci->sc_flush_request) |
279 | return; | 276 | return; |
@@ -298,6 +295,8 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | |||
298 | int gcflag) | 295 | int gcflag) |
299 | { | 296 | { |
300 | struct nilfs_transaction_info *cur_ti = current->journal_info; | 297 | 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; | ||
301 | 300 | ||
302 | WARN_ON(cur_ti); | 301 | WARN_ON(cur_ti); |
303 | ti->ti_flags = NILFS_TI_WRITER; | 302 | ti->ti_flags = NILFS_TI_WRITER; |
@@ -308,11 +307,11 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | |||
308 | current->journal_info = ti; | 307 | current->journal_info = ti; |
309 | 308 | ||
310 | for (;;) { | 309 | for (;;) { |
311 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 310 | down_write(&nilfs->ns_segctor_sem); |
312 | if (!test_bit(NILFS_SC_PRIOR_FLUSH, &NILFS_SC(sbi)->sc_flags)) | 311 | if (!test_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags)) |
313 | break; | 312 | break; |
314 | 313 | ||
315 | nilfs_segctor_do_immediate_flush(NILFS_SC(sbi)); | 314 | nilfs_segctor_do_immediate_flush(sci); |
316 | 315 | ||
317 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 316 | up_write(&sbi->s_nilfs->ns_segctor_sem); |
318 | yield(); | 317 | yield(); |
@@ -2169,8 +2168,8 @@ static void nilfs_segctor_do_flush(struct nilfs_sc_info *sci, int bn) | |||
2169 | */ | 2168 | */ |
2170 | void nilfs_flush_segment(struct super_block *sb, ino_t ino) | 2169 | void nilfs_flush_segment(struct super_block *sb, ino_t ino) |
2171 | { | 2170 | { |
2172 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2171 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
2173 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2172 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2174 | 2173 | ||
2175 | if (!sci || nilfs_doing_construction()) | 2174 | if (!sci || nilfs_doing_construction()) |
2176 | return; | 2175 | return; |
@@ -2259,8 +2258,8 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err) | |||
2259 | */ | 2258 | */ |
2260 | int nilfs_construct_segment(struct super_block *sb) | 2259 | int nilfs_construct_segment(struct super_block *sb) |
2261 | { | 2260 | { |
2262 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2261 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
2263 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2262 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2264 | struct nilfs_transaction_info *ti; | 2263 | struct nilfs_transaction_info *ti; |
2265 | int err; | 2264 | int err; |
2266 | 2265 | ||
@@ -2299,7 +2298,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, | |||
2299 | { | 2298 | { |
2300 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2299 | struct nilfs_sb_info *sbi = NILFS_SB(sb); |
2301 | struct the_nilfs *nilfs = sbi->s_nilfs; | 2300 | 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; |
2303 | struct nilfs_inode_info *ii; | 2302 | struct nilfs_inode_info *ii; |
2304 | struct nilfs_transaction_info ti; | 2303 | struct nilfs_transaction_info ti; |
2305 | int err = 0; | 2304 | int err = 0; |
@@ -2445,8 +2444,8 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | |||
2445 | void **kbufs) | 2444 | void **kbufs) |
2446 | { | 2445 | { |
2447 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2446 | struct nilfs_sb_info *sbi = NILFS_SB(sb); |
2448 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | ||
2449 | struct the_nilfs *nilfs = sbi->s_nilfs; | 2447 | struct the_nilfs *nilfs = sbi->s_nilfs; |
2448 | struct nilfs_sc_info *sci = nilfs->ns_writer; | ||
2450 | struct nilfs_transaction_info ti; | 2449 | struct nilfs_transaction_info ti; |
2451 | int err; | 2450 | int err; |
2452 | 2451 | ||
@@ -2787,9 +2786,10 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2787 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | 2786 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, |
2788 | struct nilfs_root *root) | 2787 | struct nilfs_root *root) |
2789 | { | 2788 | { |
2789 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2790 | int err; | 2790 | int err; |
2791 | 2791 | ||
2792 | if (NILFS_SC(sbi)) { | 2792 | if (nilfs->ns_writer) { |
2793 | /* | 2793 | /* |
2794 | * This happens if the filesystem was remounted | 2794 | * This happens if the filesystem was remounted |
2795 | * read/write after nilfs_error degenerated it into a | 2795 | * read/write after nilfs_error degenerated it into a |
@@ -2798,14 +2798,14 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | |||
2798 | nilfs_detach_segment_constructor(sbi); | 2798 | nilfs_detach_segment_constructor(sbi); |
2799 | } | 2799 | } |
2800 | 2800 | ||
2801 | sbi->s_sc_info = nilfs_segctor_new(sbi, root); | 2801 | nilfs->ns_writer = nilfs_segctor_new(sbi, root); |
2802 | if (!sbi->s_sc_info) | 2802 | if (!nilfs->ns_writer) |
2803 | return -ENOMEM; | 2803 | return -ENOMEM; |
2804 | 2804 | ||
2805 | err = nilfs_segctor_start_thread(NILFS_SC(sbi)); | 2805 | err = nilfs_segctor_start_thread(nilfs->ns_writer); |
2806 | if (err) { | 2806 | if (err) { |
2807 | kfree(sbi->s_sc_info); | 2807 | kfree(nilfs->ns_writer); |
2808 | sbi->s_sc_info = NULL; | 2808 | nilfs->ns_writer = NULL; |
2809 | } | 2809 | } |
2810 | return err; | 2810 | return err; |
2811 | } | 2811 | } |
@@ -2823,9 +2823,9 @@ void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) | |||
2823 | LIST_HEAD(garbage_list); | 2823 | LIST_HEAD(garbage_list); |
2824 | 2824 | ||
2825 | down_write(&nilfs->ns_segctor_sem); | 2825 | down_write(&nilfs->ns_segctor_sem); |
2826 | if (NILFS_SC(sbi)) { | 2826 | if (nilfs->ns_writer) { |
2827 | nilfs_segctor_destroy(NILFS_SC(sbi)); | 2827 | nilfs_segctor_destroy(nilfs->ns_writer); |
2828 | sbi->s_sc_info = NULL; | 2828 | nilfs->ns_writer = NULL; |
2829 | } | 2829 | } |
2830 | 2830 | ||
2831 | /* Force to free the list of dirty files */ | 2831 | /* Force to free the list of dirty files */ |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 3ecc968f2123..10521b97ded6 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include "sb.h" | 34 | #include "sb.h" |
35 | 35 | ||
36 | struct nilfs_sc_info; | ||
37 | |||
36 | /* the_nilfs struct */ | 38 | /* the_nilfs struct */ |
37 | enum { | 39 | enum { |
38 | THE_NILFS_INIT = 0, /* Information from super_block is set */ | 40 | THE_NILFS_INIT = 0, /* Information from super_block is set */ |
@@ -65,7 +67,8 @@ enum { | |||
65 | * @ns_last_cno: checkpoint number of the latest segment | 67 | * @ns_last_cno: checkpoint number of the latest segment |
66 | * @ns_prot_seq: least sequence number of segments which must not be reclaimed | 68 | * @ns_prot_seq: least sequence number of segments which must not be reclaimed |
67 | * @ns_prev_seq: base sequence number used to decide if advance log cursor | 69 | * @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 | ||
69 | * @ns_dat: DAT file inode | 72 | * @ns_dat: DAT file inode |
70 | * @ns_cpfile: checkpoint file inode | 73 | * @ns_cpfile: checkpoint file inode |
71 | * @ns_sufile: segusage file inode | 74 | * @ns_sufile: segusage file inode |
@@ -140,6 +143,7 @@ struct the_nilfs { | |||
140 | u64 ns_prot_seq; | 143 | u64 ns_prot_seq; |
141 | u64 ns_prev_seq; | 144 | u64 ns_prev_seq; |
142 | 145 | ||
146 | struct nilfs_sc_info *ns_writer; | ||
143 | struct rw_semaphore ns_segctor_sem; | 147 | struct rw_semaphore ns_segctor_sem; |
144 | 148 | ||
145 | /* | 149 | /* |