aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/journal.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2009-03-30 14:02:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-30 15:16:39 -0400
commita9dd364358fbdc68faee5d20c2d648c320dc3cf0 (patch)
treeeffcf61e5e198083faff82dc1e0bd6071639fca8 /fs/reiserfs/journal.c
parent0222e6571c332563a48d4cf5487b67feabe60b5e (diff)
reiserfs: rename p_s_sb to sb
This patch is a simple s/p_s_sb/sb/g to the reiserfs code. This is the first in a series of patches to rip out some of the awful variable naming in reiserfs. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs/journal.c')
-rw-r--r--fs/reiserfs/journal.c735
1 files changed, 367 insertions, 368 deletions
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 4f787462becc..77f5bb746bf0 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -97,7 +97,7 @@ static int flush_commit_list(struct super_block *s,
97 struct reiserfs_journal_list *jl, int flushall); 97 struct reiserfs_journal_list *jl, int flushall);
98static int can_dirty(struct reiserfs_journal_cnode *cn); 98static int can_dirty(struct reiserfs_journal_cnode *cn);
99static int journal_join(struct reiserfs_transaction_handle *th, 99static int journal_join(struct reiserfs_transaction_handle *th,
100 struct super_block *p_s_sb, unsigned long nblocks); 100 struct super_block *sb, unsigned long nblocks);
101static int release_journal_dev(struct super_block *super, 101static int release_journal_dev(struct super_block *super,
102 struct reiserfs_journal *journal); 102 struct reiserfs_journal *journal);
103static int dirty_one_transaction(struct super_block *s, 103static int dirty_one_transaction(struct super_block *s,
@@ -113,12 +113,12 @@ enum {
113}; 113};
114 114
115static int do_journal_begin_r(struct reiserfs_transaction_handle *th, 115static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
116 struct super_block *p_s_sb, 116 struct super_block *sb,
117 unsigned long nblocks, int join); 117 unsigned long nblocks, int join);
118 118
119static void init_journal_hash(struct super_block *p_s_sb) 119static void init_journal_hash(struct super_block *sb)
120{ 120{
121 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 121 struct reiserfs_journal *journal = SB_JOURNAL(sb);
122 memset(journal->j_hash_table, 0, 122 memset(journal->j_hash_table, 0,
123 JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)); 123 JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *));
124} 124}
@@ -145,7 +145,7 @@ static void disable_barrier(struct super_block *s)
145} 145}
146 146
147static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block 147static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block
148 *p_s_sb) 148 *sb)
149{ 149{
150 struct reiserfs_bitmap_node *bn; 150 struct reiserfs_bitmap_node *bn;
151 static int id; 151 static int id;
@@ -154,7 +154,7 @@ static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block
154 if (!bn) { 154 if (!bn) {
155 return NULL; 155 return NULL;
156 } 156 }
157 bn->data = kzalloc(p_s_sb->s_blocksize, GFP_NOFS); 157 bn->data = kzalloc(sb->s_blocksize, GFP_NOFS);
158 if (!bn->data) { 158 if (!bn->data) {
159 kfree(bn); 159 kfree(bn);
160 return NULL; 160 return NULL;
@@ -164,9 +164,9 @@ static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block
164 return bn; 164 return bn;
165} 165}
166 166
167static struct reiserfs_bitmap_node *get_bitmap_node(struct super_block *p_s_sb) 167static struct reiserfs_bitmap_node *get_bitmap_node(struct super_block *sb)
168{ 168{
169 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 169 struct reiserfs_journal *journal = SB_JOURNAL(sb);
170 struct reiserfs_bitmap_node *bn = NULL; 170 struct reiserfs_bitmap_node *bn = NULL;
171 struct list_head *entry = journal->j_bitmap_nodes.next; 171 struct list_head *entry = journal->j_bitmap_nodes.next;
172 172
@@ -176,21 +176,21 @@ static struct reiserfs_bitmap_node *get_bitmap_node(struct super_block *p_s_sb)
176 if (entry != &journal->j_bitmap_nodes) { 176 if (entry != &journal->j_bitmap_nodes) {
177 bn = list_entry(entry, struct reiserfs_bitmap_node, list); 177 bn = list_entry(entry, struct reiserfs_bitmap_node, list);
178 list_del(entry); 178 list_del(entry);
179 memset(bn->data, 0, p_s_sb->s_blocksize); 179 memset(bn->data, 0, sb->s_blocksize);
180 journal->j_free_bitmap_nodes--; 180 journal->j_free_bitmap_nodes--;
181 return bn; 181 return bn;
182 } 182 }
183 bn = allocate_bitmap_node(p_s_sb); 183 bn = allocate_bitmap_node(sb);
184 if (!bn) { 184 if (!bn) {
185 yield(); 185 yield();
186 goto repeat; 186 goto repeat;
187 } 187 }
188 return bn; 188 return bn;
189} 189}
190static inline void free_bitmap_node(struct super_block *p_s_sb, 190static inline void free_bitmap_node(struct super_block *sb,
191 struct reiserfs_bitmap_node *bn) 191 struct reiserfs_bitmap_node *bn)
192{ 192{
193 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 193 struct reiserfs_journal *journal = SB_JOURNAL(sb);
194 journal->j_used_bitmap_nodes--; 194 journal->j_used_bitmap_nodes--;
195 if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) { 195 if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
196 kfree(bn->data); 196 kfree(bn->data);
@@ -201,13 +201,13 @@ static inline void free_bitmap_node(struct super_block *p_s_sb,
201 } 201 }
202} 202}
203 203
204static void allocate_bitmap_nodes(struct super_block *p_s_sb) 204static void allocate_bitmap_nodes(struct super_block *sb)
205{ 205{
206 int i; 206 int i;
207 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 207 struct reiserfs_journal *journal = SB_JOURNAL(sb);
208 struct reiserfs_bitmap_node *bn = NULL; 208 struct reiserfs_bitmap_node *bn = NULL;
209 for (i = 0; i < REISERFS_MIN_BITMAP_NODES; i++) { 209 for (i = 0; i < REISERFS_MIN_BITMAP_NODES; i++) {
210 bn = allocate_bitmap_node(p_s_sb); 210 bn = allocate_bitmap_node(sb);
211 if (bn) { 211 if (bn) {
212 list_add(&bn->list, &journal->j_bitmap_nodes); 212 list_add(&bn->list, &journal->j_bitmap_nodes);
213 journal->j_free_bitmap_nodes++; 213 journal->j_free_bitmap_nodes++;
@@ -217,30 +217,30 @@ static void allocate_bitmap_nodes(struct super_block *p_s_sb)
217 } 217 }
218} 218}
219 219
220static int set_bit_in_list_bitmap(struct super_block *p_s_sb, 220static int set_bit_in_list_bitmap(struct super_block *sb,
221 b_blocknr_t block, 221 b_blocknr_t block,
222 struct reiserfs_list_bitmap *jb) 222 struct reiserfs_list_bitmap *jb)
223{ 223{
224 unsigned int bmap_nr = block / (p_s_sb->s_blocksize << 3); 224 unsigned int bmap_nr = block / (sb->s_blocksize << 3);
225 unsigned int bit_nr = block % (p_s_sb->s_blocksize << 3); 225 unsigned int bit_nr = block % (sb->s_blocksize << 3);
226 226
227 if (!jb->bitmaps[bmap_nr]) { 227 if (!jb->bitmaps[bmap_nr]) {
228 jb->bitmaps[bmap_nr] = get_bitmap_node(p_s_sb); 228 jb->bitmaps[bmap_nr] = get_bitmap_node(sb);
229 } 229 }
230 set_bit(bit_nr, (unsigned long *)jb->bitmaps[bmap_nr]->data); 230 set_bit(bit_nr, (unsigned long *)jb->bitmaps[bmap_nr]->data);
231 return 0; 231 return 0;
232} 232}
233 233
234static void cleanup_bitmap_list(struct super_block *p_s_sb, 234static void cleanup_bitmap_list(struct super_block *sb,
235 struct reiserfs_list_bitmap *jb) 235 struct reiserfs_list_bitmap *jb)
236{ 236{
237 int i; 237 int i;
238 if (jb->bitmaps == NULL) 238 if (jb->bitmaps == NULL)
239 return; 239 return;
240 240
241 for (i = 0; i < reiserfs_bmap_count(p_s_sb); i++) { 241 for (i = 0; i < reiserfs_bmap_count(sb); i++) {
242 if (jb->bitmaps[i]) { 242 if (jb->bitmaps[i]) {
243 free_bitmap_node(p_s_sb, jb->bitmaps[i]); 243 free_bitmap_node(sb, jb->bitmaps[i]);
244 jb->bitmaps[i] = NULL; 244 jb->bitmaps[i] = NULL;
245 } 245 }
246 } 246 }
@@ -249,7 +249,7 @@ static void cleanup_bitmap_list(struct super_block *p_s_sb,
249/* 249/*
250** only call this on FS unmount. 250** only call this on FS unmount.
251*/ 251*/
252static int free_list_bitmaps(struct super_block *p_s_sb, 252static int free_list_bitmaps(struct super_block *sb,
253 struct reiserfs_list_bitmap *jb_array) 253 struct reiserfs_list_bitmap *jb_array)
254{ 254{
255 int i; 255 int i;
@@ -257,16 +257,16 @@ static int free_list_bitmaps(struct super_block *p_s_sb,
257 for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) { 257 for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
258 jb = jb_array + i; 258 jb = jb_array + i;
259 jb->journal_list = NULL; 259 jb->journal_list = NULL;
260 cleanup_bitmap_list(p_s_sb, jb); 260 cleanup_bitmap_list(sb, jb);
261 vfree(jb->bitmaps); 261 vfree(jb->bitmaps);
262 jb->bitmaps = NULL; 262 jb->bitmaps = NULL;
263 } 263 }
264 return 0; 264 return 0;
265} 265}
266 266
267static int free_bitmap_nodes(struct super_block *p_s_sb) 267static int free_bitmap_nodes(struct super_block *sb)
268{ 268{
269 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 269 struct reiserfs_journal *journal = SB_JOURNAL(sb);
270 struct list_head *next = journal->j_bitmap_nodes.next; 270 struct list_head *next = journal->j_bitmap_nodes.next;
271 struct reiserfs_bitmap_node *bn; 271 struct reiserfs_bitmap_node *bn;
272 272
@@ -286,7 +286,7 @@ static int free_bitmap_nodes(struct super_block *p_s_sb)
286** get memory for JOURNAL_NUM_BITMAPS worth of bitmaps. 286** get memory for JOURNAL_NUM_BITMAPS worth of bitmaps.
287** jb_array is the array to be filled in. 287** jb_array is the array to be filled in.
288*/ 288*/
289int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb, 289int reiserfs_allocate_list_bitmaps(struct super_block *sb,
290 struct reiserfs_list_bitmap *jb_array, 290 struct reiserfs_list_bitmap *jb_array,
291 unsigned int bmap_nr) 291 unsigned int bmap_nr)
292{ 292{
@@ -300,7 +300,7 @@ int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb,
300 jb->journal_list = NULL; 300 jb->journal_list = NULL;
301 jb->bitmaps = vmalloc(mem); 301 jb->bitmaps = vmalloc(mem);
302 if (!jb->bitmaps) { 302 if (!jb->bitmaps) {
303 reiserfs_warning(p_s_sb, "clm-2000", "unable to " 303 reiserfs_warning(sb, "clm-2000", "unable to "
304 "allocate bitmaps for journal lists"); 304 "allocate bitmaps for journal lists");
305 failed = 1; 305 failed = 1;
306 break; 306 break;
@@ -308,7 +308,7 @@ int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb,
308 memset(jb->bitmaps, 0, mem); 308 memset(jb->bitmaps, 0, mem);
309 } 309 }
310 if (failed) { 310 if (failed) {
311 free_list_bitmaps(p_s_sb, jb_array); 311 free_list_bitmaps(sb, jb_array);
312 return -1; 312 return -1;
313 } 313 }
314 return 0; 314 return 0;
@@ -318,12 +318,12 @@ int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb,
318** find an available list bitmap. If you can't find one, flush a commit list 318** find an available list bitmap. If you can't find one, flush a commit list
319** and try again 319** and try again
320*/ 320*/
321static struct reiserfs_list_bitmap *get_list_bitmap(struct super_block *p_s_sb, 321static struct reiserfs_list_bitmap *get_list_bitmap(struct super_block *sb,
322 struct reiserfs_journal_list 322 struct reiserfs_journal_list
323 *jl) 323 *jl)
324{ 324{
325 int i, j; 325 int i, j;
326 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 326 struct reiserfs_journal *journal = SB_JOURNAL(sb);
327 struct reiserfs_list_bitmap *jb = NULL; 327 struct reiserfs_list_bitmap *jb = NULL;
328 328
329 for (j = 0; j < (JOURNAL_NUM_BITMAPS * 3); j++) { 329 for (j = 0; j < (JOURNAL_NUM_BITMAPS * 3); j++) {
@@ -331,7 +331,7 @@ static struct reiserfs_list_bitmap *get_list_bitmap(struct super_block *p_s_sb,
331 journal->j_list_bitmap_index = (i + 1) % JOURNAL_NUM_BITMAPS; 331 journal->j_list_bitmap_index = (i + 1) % JOURNAL_NUM_BITMAPS;
332 jb = journal->j_list_bitmap + i; 332 jb = journal->j_list_bitmap + i;
333 if (journal->j_list_bitmap[i].journal_list) { 333 if (journal->j_list_bitmap[i].journal_list) {
334 flush_commit_list(p_s_sb, 334 flush_commit_list(sb,
335 journal->j_list_bitmap[i]. 335 journal->j_list_bitmap[i].
336 journal_list, 1); 336 journal_list, 1);
337 if (!journal->j_list_bitmap[i].journal_list) { 337 if (!journal->j_list_bitmap[i].journal_list) {
@@ -378,12 +378,12 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes)
378/* 378/*
379** pulls a cnode off the free list, or returns NULL on failure 379** pulls a cnode off the free list, or returns NULL on failure
380*/ 380*/
381static struct reiserfs_journal_cnode *get_cnode(struct super_block *p_s_sb) 381static struct reiserfs_journal_cnode *get_cnode(struct super_block *sb)
382{ 382{
383 struct reiserfs_journal_cnode *cn; 383 struct reiserfs_journal_cnode *cn;
384 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 384 struct reiserfs_journal *journal = SB_JOURNAL(sb);
385 385
386 reiserfs_check_lock_depth(p_s_sb, "get_cnode"); 386 reiserfs_check_lock_depth(sb, "get_cnode");
387 387
388 if (journal->j_cnode_free <= 0) { 388 if (journal->j_cnode_free <= 0) {
389 return NULL; 389 return NULL;
@@ -405,12 +405,12 @@ static struct reiserfs_journal_cnode *get_cnode(struct super_block *p_s_sb)
405/* 405/*
406** returns a cnode to the free list 406** returns a cnode to the free list
407*/ 407*/
408static void free_cnode(struct super_block *p_s_sb, 408static void free_cnode(struct super_block *sb,
409 struct reiserfs_journal_cnode *cn) 409 struct reiserfs_journal_cnode *cn)
410{ 410{
411 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 411 struct reiserfs_journal *journal = SB_JOURNAL(sb);
412 412
413 reiserfs_check_lock_depth(p_s_sb, "free_cnode"); 413 reiserfs_check_lock_depth(sb, "free_cnode");
414 414
415 journal->j_cnode_used--; 415 journal->j_cnode_used--;
416 journal->j_cnode_free++; 416 journal->j_cnode_free++;
@@ -481,11 +481,11 @@ static inline struct reiserfs_journal_cnode *get_journal_hash_dev(struct
481** reject it on the next call to reiserfs_in_journal 481** reject it on the next call to reiserfs_in_journal
482** 482**
483*/ 483*/
484int reiserfs_in_journal(struct super_block *p_s_sb, 484int reiserfs_in_journal(struct super_block *sb,
485 unsigned int bmap_nr, int bit_nr, int search_all, 485 unsigned int bmap_nr, int bit_nr, int search_all,
486 b_blocknr_t * next_zero_bit) 486 b_blocknr_t * next_zero_bit)
487{ 487{
488 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 488 struct reiserfs_journal *journal = SB_JOURNAL(sb);
489 struct reiserfs_journal_cnode *cn; 489 struct reiserfs_journal_cnode *cn;
490 struct reiserfs_list_bitmap *jb; 490 struct reiserfs_list_bitmap *jb;
491 int i; 491 int i;
@@ -493,14 +493,14 @@ int reiserfs_in_journal(struct super_block *p_s_sb,
493 493
494 *next_zero_bit = 0; /* always start this at zero. */ 494 *next_zero_bit = 0; /* always start this at zero. */
495 495
496 PROC_INFO_INC(p_s_sb, journal.in_journal); 496 PROC_INFO_INC(sb, journal.in_journal);
497 /* If we aren't doing a search_all, this is a metablock, and it will be logged before use. 497 /* If we aren't doing a search_all, this is a metablock, and it will be logged before use.
498 ** if we crash before the transaction that freed it commits, this transaction won't 498 ** if we crash before the transaction that freed it commits, this transaction won't
499 ** have committed either, and the block will never be written 499 ** have committed either, and the block will never be written
500 */ 500 */
501 if (search_all) { 501 if (search_all) {
502 for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) { 502 for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
503 PROC_INFO_INC(p_s_sb, journal.in_journal_bitmap); 503 PROC_INFO_INC(sb, journal.in_journal_bitmap);
504 jb = journal->j_list_bitmap + i; 504 jb = journal->j_list_bitmap + i;
505 if (jb->journal_list && jb->bitmaps[bmap_nr] && 505 if (jb->journal_list && jb->bitmaps[bmap_nr] &&
506 test_bit(bit_nr, 506 test_bit(bit_nr,
@@ -510,28 +510,28 @@ int reiserfs_in_journal(struct super_block *p_s_sb,
510 find_next_zero_bit((unsigned long *) 510 find_next_zero_bit((unsigned long *)
511 (jb->bitmaps[bmap_nr]-> 511 (jb->bitmaps[bmap_nr]->
512 data), 512 data),
513 p_s_sb->s_blocksize << 3, 513 sb->s_blocksize << 3,
514 bit_nr + 1); 514 bit_nr + 1);
515 return 1; 515 return 1;
516 } 516 }
517 } 517 }
518 } 518 }
519 519
520 bl = bmap_nr * (p_s_sb->s_blocksize << 3) + bit_nr; 520 bl = bmap_nr * (sb->s_blocksize << 3) + bit_nr;
521 /* is it in any old transactions? */ 521 /* is it in any old transactions? */
522 if (search_all 522 if (search_all
523 && (cn = 523 && (cn =
524 get_journal_hash_dev(p_s_sb, journal->j_list_hash_table, bl))) { 524 get_journal_hash_dev(sb, journal->j_list_hash_table, bl))) {
525 return 1; 525 return 1;
526 } 526 }
527 527
528 /* is it in the current transaction. This should never happen */ 528 /* is it in the current transaction. This should never happen */
529 if ((cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, bl))) { 529 if ((cn = get_journal_hash_dev(sb, journal->j_hash_table, bl))) {
530 BUG(); 530 BUG();
531 return 1; 531 return 1;
532 } 532 }
533 533
534 PROC_INFO_INC(p_s_sb, journal.in_journal_reusable); 534 PROC_INFO_INC(sb, journal.in_journal_reusable);
535 /* safe for reuse */ 535 /* safe for reuse */
536 return 0; 536 return 0;
537} 537}
@@ -553,16 +553,16 @@ static inline void insert_journal_hash(struct reiserfs_journal_cnode **table,
553} 553}
554 554
555/* lock the current transaction */ 555/* lock the current transaction */
556static inline void lock_journal(struct super_block *p_s_sb) 556static inline void lock_journal(struct super_block *sb)
557{ 557{
558 PROC_INFO_INC(p_s_sb, journal.lock_journal); 558 PROC_INFO_INC(sb, journal.lock_journal);
559 mutex_lock(&SB_JOURNAL(p_s_sb)->j_mutex); 559 mutex_lock(&SB_JOURNAL(sb)->j_mutex);
560} 560}
561 561
562/* unlock the current transaction */ 562/* unlock the current transaction */
563static inline void unlock_journal(struct super_block *p_s_sb) 563static inline void unlock_journal(struct super_block *sb)
564{ 564{
565 mutex_unlock(&SB_JOURNAL(p_s_sb)->j_mutex); 565 mutex_unlock(&SB_JOURNAL(sb)->j_mutex);
566} 566}
567 567
568static inline void get_journal_list(struct reiserfs_journal_list *jl) 568static inline void get_journal_list(struct reiserfs_journal_list *jl)
@@ -586,13 +586,13 @@ static inline void put_journal_list(struct super_block *s,
586** it gets called by flush_commit_list, and cleans up any data stored about blocks freed during a 586** it gets called by flush_commit_list, and cleans up any data stored about blocks freed during a
587** transaction. 587** transaction.
588*/ 588*/
589static void cleanup_freed_for_journal_list(struct super_block *p_s_sb, 589static void cleanup_freed_for_journal_list(struct super_block *sb,
590 struct reiserfs_journal_list *jl) 590 struct reiserfs_journal_list *jl)
591{ 591{
592 592
593 struct reiserfs_list_bitmap *jb = jl->j_list_bitmap; 593 struct reiserfs_list_bitmap *jb = jl->j_list_bitmap;
594 if (jb) { 594 if (jb) {
595 cleanup_bitmap_list(p_s_sb, jb); 595 cleanup_bitmap_list(sb, jb);
596 } 596 }
597 jl->j_list_bitmap->journal_list = NULL; 597 jl->j_list_bitmap->journal_list = NULL;
598 jl->j_list_bitmap = NULL; 598 jl->j_list_bitmap = NULL;
@@ -1237,11 +1237,11 @@ static void remove_journal_hash(struct super_block *,
1237** journal list for this transaction. Aside from freeing the cnode, this also allows the 1237** journal list for this transaction. Aside from freeing the cnode, this also allows the
1238** block to be reallocated for data blocks if it had been deleted. 1238** block to be reallocated for data blocks if it had been deleted.
1239*/ 1239*/
1240static void remove_all_from_journal_list(struct super_block *p_s_sb, 1240static void remove_all_from_journal_list(struct super_block *sb,
1241 struct reiserfs_journal_list *jl, 1241 struct reiserfs_journal_list *jl,
1242 int debug) 1242 int debug)
1243{ 1243{
1244 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 1244 struct reiserfs_journal *journal = SB_JOURNAL(sb);
1245 struct reiserfs_journal_cnode *cn, *last; 1245 struct reiserfs_journal_cnode *cn, *last;
1246 cn = jl->j_realblock; 1246 cn = jl->j_realblock;
1247 1247
@@ -1251,18 +1251,18 @@ static void remove_all_from_journal_list(struct super_block *p_s_sb,
1251 while (cn) { 1251 while (cn) {
1252 if (cn->blocknr != 0) { 1252 if (cn->blocknr != 0) {
1253 if (debug) { 1253 if (debug) {
1254 reiserfs_warning(p_s_sb, "reiserfs-2201", 1254 reiserfs_warning(sb, "reiserfs-2201",
1255 "block %u, bh is %d, state %ld", 1255 "block %u, bh is %d, state %ld",
1256 cn->blocknr, cn->bh ? 1 : 0, 1256 cn->blocknr, cn->bh ? 1 : 0,
1257 cn->state); 1257 cn->state);
1258 } 1258 }
1259 cn->state = 0; 1259 cn->state = 0;
1260 remove_journal_hash(p_s_sb, journal->j_list_hash_table, 1260 remove_journal_hash(sb, journal->j_list_hash_table,
1261 jl, cn->blocknr, 1); 1261 jl, cn->blocknr, 1);
1262 } 1262 }
1263 last = cn; 1263 last = cn;
1264 cn = cn->next; 1264 cn = cn->next;
1265 free_cnode(p_s_sb, last); 1265 free_cnode(sb, last);
1266 } 1266 }
1267 jl->j_realblock = NULL; 1267 jl->j_realblock = NULL;
1268} 1268}
@@ -1274,12 +1274,12 @@ static void remove_all_from_journal_list(struct super_block *p_s_sb,
1274** called by flush_journal_list, before it calls remove_all_from_journal_list 1274** called by flush_journal_list, before it calls remove_all_from_journal_list
1275** 1275**
1276*/ 1276*/
1277static int _update_journal_header_block(struct super_block *p_s_sb, 1277static int _update_journal_header_block(struct super_block *sb,
1278 unsigned long offset, 1278 unsigned long offset,
1279 unsigned int trans_id) 1279 unsigned int trans_id)
1280{ 1280{
1281 struct reiserfs_journal_header *jh; 1281 struct reiserfs_journal_header *jh;
1282 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 1282 struct reiserfs_journal *journal = SB_JOURNAL(sb);
1283 1283
1284 if (reiserfs_is_journal_aborted(journal)) 1284 if (reiserfs_is_journal_aborted(journal))
1285 return -EIO; 1285 return -EIO;
@@ -1289,7 +1289,7 @@ static int _update_journal_header_block(struct super_block *p_s_sb,
1289 wait_on_buffer((journal->j_header_bh)); 1289 wait_on_buffer((journal->j_header_bh));
1290 if (unlikely(!buffer_uptodate(journal->j_header_bh))) { 1290 if (unlikely(!buffer_uptodate(journal->j_header_bh))) {
1291#ifdef CONFIG_REISERFS_CHECK 1291#ifdef CONFIG_REISERFS_CHECK
1292 reiserfs_warning(p_s_sb, "journal-699", 1292 reiserfs_warning(sb, "journal-699",
1293 "buffer write failed"); 1293 "buffer write failed");
1294#endif 1294#endif
1295 return -EIO; 1295 return -EIO;
@@ -1303,24 +1303,24 @@ static int _update_journal_header_block(struct super_block *p_s_sb,
1303 jh->j_first_unflushed_offset = cpu_to_le32(offset); 1303 jh->j_first_unflushed_offset = cpu_to_le32(offset);
1304 jh->j_mount_id = cpu_to_le32(journal->j_mount_id); 1304 jh->j_mount_id = cpu_to_le32(journal->j_mount_id);
1305 1305
1306 if (reiserfs_barrier_flush(p_s_sb)) { 1306 if (reiserfs_barrier_flush(sb)) {
1307 int ret; 1307 int ret;
1308 lock_buffer(journal->j_header_bh); 1308 lock_buffer(journal->j_header_bh);
1309 ret = submit_barrier_buffer(journal->j_header_bh); 1309 ret = submit_barrier_buffer(journal->j_header_bh);
1310 if (ret == -EOPNOTSUPP) { 1310 if (ret == -EOPNOTSUPP) {
1311 set_buffer_uptodate(journal->j_header_bh); 1311 set_buffer_uptodate(journal->j_header_bh);
1312 disable_barrier(p_s_sb); 1312 disable_barrier(sb);
1313 goto sync; 1313 goto sync;
1314 } 1314 }
1315 wait_on_buffer(journal->j_header_bh); 1315 wait_on_buffer(journal->j_header_bh);
1316 check_barrier_completion(p_s_sb, journal->j_header_bh); 1316 check_barrier_completion(sb, journal->j_header_bh);
1317 } else { 1317 } else {
1318 sync: 1318 sync:
1319 set_buffer_dirty(journal->j_header_bh); 1319 set_buffer_dirty(journal->j_header_bh);
1320 sync_dirty_buffer(journal->j_header_bh); 1320 sync_dirty_buffer(journal->j_header_bh);
1321 } 1321 }
1322 if (!buffer_uptodate(journal->j_header_bh)) { 1322 if (!buffer_uptodate(journal->j_header_bh)) {
1323 reiserfs_warning(p_s_sb, "journal-837", 1323 reiserfs_warning(sb, "journal-837",
1324 "IO error during journal replay"); 1324 "IO error during journal replay");
1325 return -EIO; 1325 return -EIO;
1326 } 1326 }
@@ -1328,23 +1328,23 @@ static int _update_journal_header_block(struct super_block *p_s_sb,
1328 return 0; 1328 return 0;
1329} 1329}
1330 1330
1331static int update_journal_header_block(struct super_block *p_s_sb, 1331static int update_journal_header_block(struct super_block *sb,
1332 unsigned long offset, 1332 unsigned long offset,
1333 unsigned int trans_id) 1333 unsigned int trans_id)
1334{ 1334{
1335 return _update_journal_header_block(p_s_sb, offset, trans_id); 1335 return _update_journal_header_block(sb, offset, trans_id);
1336} 1336}
1337 1337
1338/* 1338/*
1339** flush any and all journal lists older than you are 1339** flush any and all journal lists older than you are
1340** can only be called from flush_journal_list 1340** can only be called from flush_journal_list
1341*/ 1341*/
1342static int flush_older_journal_lists(struct super_block *p_s_sb, 1342static int flush_older_journal_lists(struct super_block *sb,
1343 struct reiserfs_journal_list *jl) 1343 struct reiserfs_journal_list *jl)
1344{ 1344{
1345 struct list_head *entry; 1345 struct list_head *entry;
1346 struct reiserfs_journal_list *other_jl; 1346 struct reiserfs_journal_list *other_jl;
1347 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 1347 struct reiserfs_journal *journal = SB_JOURNAL(sb);
1348 unsigned int trans_id = jl->j_trans_id; 1348 unsigned int trans_id = jl->j_trans_id;
1349 1349
1350 /* we know we are the only ones flushing things, no extra race 1350 /* we know we are the only ones flushing things, no extra race
@@ -1359,7 +1359,7 @@ static int flush_older_journal_lists(struct super_block *p_s_sb,
1359 if (other_jl->j_trans_id < trans_id) { 1359 if (other_jl->j_trans_id < trans_id) {
1360 BUG_ON(other_jl->j_refcount <= 0); 1360 BUG_ON(other_jl->j_refcount <= 0);
1361 /* do not flush all */ 1361 /* do not flush all */
1362 flush_journal_list(p_s_sb, other_jl, 0); 1362 flush_journal_list(sb, other_jl, 0);
1363 1363
1364 /* other_jl is now deleted from the list */ 1364 /* other_jl is now deleted from the list */
1365 goto restart; 1365 goto restart;
@@ -1908,22 +1908,22 @@ void remove_journal_hash(struct super_block *sb,
1908 } 1908 }
1909} 1909}
1910 1910
1911static void free_journal_ram(struct super_block *p_s_sb) 1911static void free_journal_ram(struct super_block *sb)
1912{ 1912{
1913 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 1913 struct reiserfs_journal *journal = SB_JOURNAL(sb);
1914 kfree(journal->j_current_jl); 1914 kfree(journal->j_current_jl);
1915 journal->j_num_lists--; 1915 journal->j_num_lists--;
1916 1916
1917 vfree(journal->j_cnode_free_orig); 1917 vfree(journal->j_cnode_free_orig);
1918 free_list_bitmaps(p_s_sb, journal->j_list_bitmap); 1918 free_list_bitmaps(sb, journal->j_list_bitmap);
1919 free_bitmap_nodes(p_s_sb); /* must be after free_list_bitmaps */ 1919 free_bitmap_nodes(sb); /* must be after free_list_bitmaps */
1920 if (journal->j_header_bh) { 1920 if (journal->j_header_bh) {
1921 brelse(journal->j_header_bh); 1921 brelse(journal->j_header_bh);
1922 } 1922 }
1923 /* j_header_bh is on the journal dev, make sure not to release the journal 1923 /* j_header_bh is on the journal dev, make sure not to release the journal
1924 * dev until we brelse j_header_bh 1924 * dev until we brelse j_header_bh
1925 */ 1925 */
1926 release_journal_dev(p_s_sb, journal); 1926 release_journal_dev(sb, journal);
1927 vfree(journal); 1927 vfree(journal);
1928} 1928}
1929 1929
@@ -1932,27 +1932,27 @@ static void free_journal_ram(struct super_block *p_s_sb)
1932** of read_super() yet. Any other caller must keep error at 0. 1932** of read_super() yet. Any other caller must keep error at 0.
1933*/ 1933*/
1934static int do_journal_release(struct reiserfs_transaction_handle *th, 1934static int do_journal_release(struct reiserfs_transaction_handle *th,
1935 struct super_block *p_s_sb, int error) 1935 struct super_block *sb, int error)
1936{ 1936{
1937 struct reiserfs_transaction_handle myth; 1937 struct reiserfs_transaction_handle myth;
1938 int flushed = 0; 1938 int flushed = 0;
1939 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 1939 struct reiserfs_journal *journal = SB_JOURNAL(sb);
1940 1940
1941 /* we only want to flush out transactions if we were called with error == 0 1941 /* we only want to flush out transactions if we were called with error == 0
1942 */ 1942 */
1943 if (!error && !(p_s_sb->s_flags & MS_RDONLY)) { 1943 if (!error && !(sb->s_flags & MS_RDONLY)) {
1944 /* end the current trans */ 1944 /* end the current trans */
1945 BUG_ON(!th->t_trans_id); 1945 BUG_ON(!th->t_trans_id);
1946 do_journal_end(th, p_s_sb, 10, FLUSH_ALL); 1946 do_journal_end(th, sb, 10, FLUSH_ALL);
1947 1947
1948 /* make sure something gets logged to force our way into the flush code */ 1948 /* make sure something gets logged to force our way into the flush code */
1949 if (!journal_join(&myth, p_s_sb, 1)) { 1949 if (!journal_join(&myth, sb, 1)) {
1950 reiserfs_prepare_for_journal(p_s_sb, 1950 reiserfs_prepare_for_journal(sb,
1951 SB_BUFFER_WITH_SB(p_s_sb), 1951 SB_BUFFER_WITH_SB(sb),
1952 1); 1952 1);
1953 journal_mark_dirty(&myth, p_s_sb, 1953 journal_mark_dirty(&myth, sb,
1954 SB_BUFFER_WITH_SB(p_s_sb)); 1954 SB_BUFFER_WITH_SB(sb));
1955 do_journal_end(&myth, p_s_sb, 1, FLUSH_ALL); 1955 do_journal_end(&myth, sb, 1, FLUSH_ALL);
1956 flushed = 1; 1956 flushed = 1;
1957 } 1957 }
1958 } 1958 }
@@ -1960,26 +1960,26 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
1960 /* this also catches errors during the do_journal_end above */ 1960 /* this also catches errors during the do_journal_end above */
1961 if (!error && reiserfs_is_journal_aborted(journal)) { 1961 if (!error && reiserfs_is_journal_aborted(journal)) {
1962 memset(&myth, 0, sizeof(myth)); 1962 memset(&myth, 0, sizeof(myth));
1963 if (!journal_join_abort(&myth, p_s_sb, 1)) { 1963 if (!journal_join_abort(&myth, sb, 1)) {
1964 reiserfs_prepare_for_journal(p_s_sb, 1964 reiserfs_prepare_for_journal(sb,
1965 SB_BUFFER_WITH_SB(p_s_sb), 1965 SB_BUFFER_WITH_SB(sb),
1966 1); 1966 1);
1967 journal_mark_dirty(&myth, p_s_sb, 1967 journal_mark_dirty(&myth, sb,
1968 SB_BUFFER_WITH_SB(p_s_sb)); 1968 SB_BUFFER_WITH_SB(sb));
1969 do_journal_end(&myth, p_s_sb, 1, FLUSH_ALL); 1969 do_journal_end(&myth, sb, 1, FLUSH_ALL);
1970 } 1970 }
1971 } 1971 }
1972 1972
1973 reiserfs_mounted_fs_count--; 1973 reiserfs_mounted_fs_count--;
1974 /* wait for all commits to finish */ 1974 /* wait for all commits to finish */
1975 cancel_delayed_work(&SB_JOURNAL(p_s_sb)->j_work); 1975 cancel_delayed_work(&SB_JOURNAL(sb)->j_work);
1976 flush_workqueue(commit_wq); 1976 flush_workqueue(commit_wq);
1977 if (!reiserfs_mounted_fs_count) { 1977 if (!reiserfs_mounted_fs_count) {
1978 destroy_workqueue(commit_wq); 1978 destroy_workqueue(commit_wq);
1979 commit_wq = NULL; 1979 commit_wq = NULL;
1980 } 1980 }
1981 1981
1982 free_journal_ram(p_s_sb); 1982 free_journal_ram(sb);
1983 1983
1984 return 0; 1984 return 0;
1985} 1985}
@@ -1988,28 +1988,28 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
1988** call on unmount. flush all journal trans, release all alloc'd ram 1988** call on unmount. flush all journal trans, release all alloc'd ram
1989*/ 1989*/
1990int journal_release(struct reiserfs_transaction_handle *th, 1990int journal_release(struct reiserfs_transaction_handle *th,
1991 struct super_block *p_s_sb) 1991 struct super_block *sb)
1992{ 1992{
1993 return do_journal_release(th, p_s_sb, 0); 1993 return do_journal_release(th, sb, 0);
1994} 1994}
1995 1995
1996/* 1996/*
1997** only call from an error condition inside reiserfs_read_super! 1997** only call from an error condition inside reiserfs_read_super!
1998*/ 1998*/
1999int journal_release_error(struct reiserfs_transaction_handle *th, 1999int journal_release_error(struct reiserfs_transaction_handle *th,
2000 struct super_block *p_s_sb) 2000 struct super_block *sb)
2001{ 2001{
2002 return do_journal_release(th, p_s_sb, 1); 2002 return do_journal_release(th, sb, 1);
2003} 2003}
2004 2004
2005/* compares description block with commit block. returns 1 if they differ, 0 if they are the same */ 2005/* compares description block with commit block. returns 1 if they differ, 0 if they are the same */
2006static int journal_compare_desc_commit(struct super_block *p_s_sb, 2006static int journal_compare_desc_commit(struct super_block *sb,
2007 struct reiserfs_journal_desc *desc, 2007 struct reiserfs_journal_desc *desc,
2008 struct reiserfs_journal_commit *commit) 2008 struct reiserfs_journal_commit *commit)
2009{ 2009{
2010 if (get_commit_trans_id(commit) != get_desc_trans_id(desc) || 2010 if (get_commit_trans_id(commit) != get_desc_trans_id(desc) ||
2011 get_commit_trans_len(commit) != get_desc_trans_len(desc) || 2011 get_commit_trans_len(commit) != get_desc_trans_len(desc) ||
2012 get_commit_trans_len(commit) > SB_JOURNAL(p_s_sb)->j_trans_max || 2012 get_commit_trans_len(commit) > SB_JOURNAL(sb)->j_trans_max ||
2013 get_commit_trans_len(commit) <= 0) { 2013 get_commit_trans_len(commit) <= 0) {
2014 return 1; 2014 return 1;
2015 } 2015 }
@@ -2020,7 +2020,7 @@ static int journal_compare_desc_commit(struct super_block *p_s_sb,
2020** returns -1 if it found a corrupt commit block 2020** returns -1 if it found a corrupt commit block
2021** returns 1 if both desc and commit were valid 2021** returns 1 if both desc and commit were valid
2022*/ 2022*/
2023static int journal_transaction_is_valid(struct super_block *p_s_sb, 2023static int journal_transaction_is_valid(struct super_block *sb,
2024 struct buffer_head *d_bh, 2024 struct buffer_head *d_bh,
2025 unsigned int *oldest_invalid_trans_id, 2025 unsigned int *oldest_invalid_trans_id,
2026 unsigned long *newest_mount_id) 2026 unsigned long *newest_mount_id)
@@ -2038,7 +2038,7 @@ static int journal_transaction_is_valid(struct super_block *p_s_sb,
2038 && !memcmp(get_journal_desc_magic(d_bh), JOURNAL_DESC_MAGIC, 8)) { 2038 && !memcmp(get_journal_desc_magic(d_bh), JOURNAL_DESC_MAGIC, 8)) {
2039 if (oldest_invalid_trans_id && *oldest_invalid_trans_id 2039 if (oldest_invalid_trans_id && *oldest_invalid_trans_id
2040 && get_desc_trans_id(desc) > *oldest_invalid_trans_id) { 2040 && get_desc_trans_id(desc) > *oldest_invalid_trans_id) {
2041 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2041 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2042 "journal-986: transaction " 2042 "journal-986: transaction "
2043 "is valid returning because trans_id %d is greater than " 2043 "is valid returning because trans_id %d is greater than "
2044 "oldest_invalid %lu", 2044 "oldest_invalid %lu",
@@ -2048,7 +2048,7 @@ static int journal_transaction_is_valid(struct super_block *p_s_sb,
2048 } 2048 }
2049 if (newest_mount_id 2049 if (newest_mount_id
2050 && *newest_mount_id > get_desc_mount_id(desc)) { 2050 && *newest_mount_id > get_desc_mount_id(desc)) {
2051 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2051 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2052 "journal-1087: transaction " 2052 "journal-1087: transaction "
2053 "is valid returning because mount_id %d is less than " 2053 "is valid returning because mount_id %d is less than "
2054 "newest_mount_id %lu", 2054 "newest_mount_id %lu",
@@ -2056,37 +2056,37 @@ static int journal_transaction_is_valid(struct super_block *p_s_sb,
2056 *newest_mount_id); 2056 *newest_mount_id);
2057 return -1; 2057 return -1;
2058 } 2058 }
2059 if (get_desc_trans_len(desc) > SB_JOURNAL(p_s_sb)->j_trans_max) { 2059 if (get_desc_trans_len(desc) > SB_JOURNAL(sb)->j_trans_max) {
2060 reiserfs_warning(p_s_sb, "journal-2018", 2060 reiserfs_warning(sb, "journal-2018",
2061 "Bad transaction length %d " 2061 "Bad transaction length %d "
2062 "encountered, ignoring transaction", 2062 "encountered, ignoring transaction",
2063 get_desc_trans_len(desc)); 2063 get_desc_trans_len(desc));
2064 return -1; 2064 return -1;
2065 } 2065 }
2066 offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); 2066 offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(sb);
2067 2067
2068 /* ok, we have a journal description block, lets see if the transaction was valid */ 2068 /* ok, we have a journal description block, lets see if the transaction was valid */
2069 c_bh = 2069 c_bh =
2070 journal_bread(p_s_sb, 2070 journal_bread(sb,
2071 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2071 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2072 ((offset + get_desc_trans_len(desc) + 2072 ((offset + get_desc_trans_len(desc) +
2073 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))); 2073 1) % SB_ONDISK_JOURNAL_SIZE(sb)));
2074 if (!c_bh) 2074 if (!c_bh)
2075 return 0; 2075 return 0;
2076 commit = (struct reiserfs_journal_commit *)c_bh->b_data; 2076 commit = (struct reiserfs_journal_commit *)c_bh->b_data;
2077 if (journal_compare_desc_commit(p_s_sb, desc, commit)) { 2077 if (journal_compare_desc_commit(sb, desc, commit)) {
2078 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2078 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2079 "journal_transaction_is_valid, commit offset %ld had bad " 2079 "journal_transaction_is_valid, commit offset %ld had bad "
2080 "time %d or length %d", 2080 "time %d or length %d",
2081 c_bh->b_blocknr - 2081 c_bh->b_blocknr -
2082 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), 2082 SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2083 get_commit_trans_id(commit), 2083 get_commit_trans_id(commit),
2084 get_commit_trans_len(commit)); 2084 get_commit_trans_len(commit));
2085 brelse(c_bh); 2085 brelse(c_bh);
2086 if (oldest_invalid_trans_id) { 2086 if (oldest_invalid_trans_id) {
2087 *oldest_invalid_trans_id = 2087 *oldest_invalid_trans_id =
2088 get_desc_trans_id(desc); 2088 get_desc_trans_id(desc);
2089 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2089 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2090 "journal-1004: " 2090 "journal-1004: "
2091 "transaction_is_valid setting oldest invalid trans_id " 2091 "transaction_is_valid setting oldest invalid trans_id "
2092 "to %d", 2092 "to %d",
@@ -2095,11 +2095,11 @@ static int journal_transaction_is_valid(struct super_block *p_s_sb,
2095 return -1; 2095 return -1;
2096 } 2096 }
2097 brelse(c_bh); 2097 brelse(c_bh);
2098 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2098 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2099 "journal-1006: found valid " 2099 "journal-1006: found valid "
2100 "transaction start offset %llu, len %d id %d", 2100 "transaction start offset %llu, len %d id %d",
2101 d_bh->b_blocknr - 2101 d_bh->b_blocknr -
2102 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), 2102 SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2103 get_desc_trans_len(desc), 2103 get_desc_trans_len(desc),
2104 get_desc_trans_id(desc)); 2104 get_desc_trans_id(desc));
2105 return 1; 2105 return 1;
@@ -2121,13 +2121,13 @@ static void brelse_array(struct buffer_head **heads, int num)
2121** this either reads in a replays a transaction, or returns because the transaction 2121** this either reads in a replays a transaction, or returns because the transaction
2122** is invalid, or too old. 2122** is invalid, or too old.
2123*/ 2123*/
2124static int journal_read_transaction(struct super_block *p_s_sb, 2124static int journal_read_transaction(struct super_block *sb,
2125 unsigned long cur_dblock, 2125 unsigned long cur_dblock,
2126 unsigned long oldest_start, 2126 unsigned long oldest_start,
2127 unsigned int oldest_trans_id, 2127 unsigned int oldest_trans_id,
2128 unsigned long newest_mount_id) 2128 unsigned long newest_mount_id)
2129{ 2129{
2130 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 2130 struct reiserfs_journal *journal = SB_JOURNAL(sb);
2131 struct reiserfs_journal_desc *desc; 2131 struct reiserfs_journal_desc *desc;
2132 struct reiserfs_journal_commit *commit; 2132 struct reiserfs_journal_commit *commit;
2133 unsigned int trans_id = 0; 2133 unsigned int trans_id = 0;
@@ -2139,45 +2139,45 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2139 int i; 2139 int i;
2140 int trans_half; 2140 int trans_half;
2141 2141
2142 d_bh = journal_bread(p_s_sb, cur_dblock); 2142 d_bh = journal_bread(sb, cur_dblock);
2143 if (!d_bh) 2143 if (!d_bh)
2144 return 1; 2144 return 1;
2145 desc = (struct reiserfs_journal_desc *)d_bh->b_data; 2145 desc = (struct reiserfs_journal_desc *)d_bh->b_data;
2146 trans_offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); 2146 trans_offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(sb);
2147 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1037: " 2147 reiserfs_debug(sb, REISERFS_DEBUG_CODE, "journal-1037: "
2148 "journal_read_transaction, offset %llu, len %d mount_id %d", 2148 "journal_read_transaction, offset %llu, len %d mount_id %d",
2149 d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), 2149 d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2150 get_desc_trans_len(desc), get_desc_mount_id(desc)); 2150 get_desc_trans_len(desc), get_desc_mount_id(desc));
2151 if (get_desc_trans_id(desc) < oldest_trans_id) { 2151 if (get_desc_trans_id(desc) < oldest_trans_id) {
2152 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1039: " 2152 reiserfs_debug(sb, REISERFS_DEBUG_CODE, "journal-1039: "
2153 "journal_read_trans skipping because %lu is too old", 2153 "journal_read_trans skipping because %lu is too old",
2154 cur_dblock - 2154 cur_dblock -
2155 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb)); 2155 SB_ONDISK_JOURNAL_1st_BLOCK(sb));
2156 brelse(d_bh); 2156 brelse(d_bh);
2157 return 1; 2157 return 1;
2158 } 2158 }
2159 if (get_desc_mount_id(desc) != newest_mount_id) { 2159 if (get_desc_mount_id(desc) != newest_mount_id) {
2160 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1146: " 2160 reiserfs_debug(sb, REISERFS_DEBUG_CODE, "journal-1146: "
2161 "journal_read_trans skipping because %d is != " 2161 "journal_read_trans skipping because %d is != "
2162 "newest_mount_id %lu", get_desc_mount_id(desc), 2162 "newest_mount_id %lu", get_desc_mount_id(desc),
2163 newest_mount_id); 2163 newest_mount_id);
2164 brelse(d_bh); 2164 brelse(d_bh);
2165 return 1; 2165 return 1;
2166 } 2166 }
2167 c_bh = journal_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2167 c_bh = journal_bread(sb, SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2168 ((trans_offset + get_desc_trans_len(desc) + 1) % 2168 ((trans_offset + get_desc_trans_len(desc) + 1) %
2169 SB_ONDISK_JOURNAL_SIZE(p_s_sb))); 2169 SB_ONDISK_JOURNAL_SIZE(sb)));
2170 if (!c_bh) { 2170 if (!c_bh) {
2171 brelse(d_bh); 2171 brelse(d_bh);
2172 return 1; 2172 return 1;
2173 } 2173 }
2174 commit = (struct reiserfs_journal_commit *)c_bh->b_data; 2174 commit = (struct reiserfs_journal_commit *)c_bh->b_data;
2175 if (journal_compare_desc_commit(p_s_sb, desc, commit)) { 2175 if (journal_compare_desc_commit(sb, desc, commit)) {
2176 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2176 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2177 "journal_read_transaction, " 2177 "journal_read_transaction, "
2178 "commit offset %llu had bad time %d or length %d", 2178 "commit offset %llu had bad time %d or length %d",
2179 c_bh->b_blocknr - 2179 c_bh->b_blocknr -
2180 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), 2180 SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2181 get_commit_trans_id(commit), 2181 get_commit_trans_id(commit),
2182 get_commit_trans_len(commit)); 2182 get_commit_trans_len(commit));
2183 brelse(c_bh); 2183 brelse(c_bh);
@@ -2195,30 +2195,30 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2195 brelse(d_bh); 2195 brelse(d_bh);
2196 kfree(log_blocks); 2196 kfree(log_blocks);
2197 kfree(real_blocks); 2197 kfree(real_blocks);
2198 reiserfs_warning(p_s_sb, "journal-1169", 2198 reiserfs_warning(sb, "journal-1169",
2199 "kmalloc failed, unable to mount FS"); 2199 "kmalloc failed, unable to mount FS");
2200 return -1; 2200 return -1;
2201 } 2201 }
2202 /* get all the buffer heads */ 2202 /* get all the buffer heads */
2203 trans_half = journal_trans_half(p_s_sb->s_blocksize); 2203 trans_half = journal_trans_half(sb->s_blocksize);
2204 for (i = 0; i < get_desc_trans_len(desc); i++) { 2204 for (i = 0; i < get_desc_trans_len(desc); i++) {
2205 log_blocks[i] = 2205 log_blocks[i] =
2206 journal_getblk(p_s_sb, 2206 journal_getblk(sb,
2207 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2207 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2208 (trans_offset + 1 + 2208 (trans_offset + 1 +
2209 i) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)); 2209 i) % SB_ONDISK_JOURNAL_SIZE(sb));
2210 if (i < trans_half) { 2210 if (i < trans_half) {
2211 real_blocks[i] = 2211 real_blocks[i] =
2212 sb_getblk(p_s_sb, 2212 sb_getblk(sb,
2213 le32_to_cpu(desc->j_realblock[i])); 2213 le32_to_cpu(desc->j_realblock[i]));
2214 } else { 2214 } else {
2215 real_blocks[i] = 2215 real_blocks[i] =
2216 sb_getblk(p_s_sb, 2216 sb_getblk(sb,
2217 le32_to_cpu(commit-> 2217 le32_to_cpu(commit->
2218 j_realblock[i - trans_half])); 2218 j_realblock[i - trans_half]));
2219 } 2219 }
2220 if (real_blocks[i]->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) { 2220 if (real_blocks[i]->b_blocknr > SB_BLOCK_COUNT(sb)) {
2221 reiserfs_warning(p_s_sb, "journal-1207", 2221 reiserfs_warning(sb, "journal-1207",
2222 "REPLAY FAILURE fsck required! " 2222 "REPLAY FAILURE fsck required! "
2223 "Block to replay is outside of " 2223 "Block to replay is outside of "
2224 "filesystem"); 2224 "filesystem");
@@ -2226,8 +2226,8 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2226 } 2226 }
2227 /* make sure we don't try to replay onto log or reserved area */ 2227 /* make sure we don't try to replay onto log or reserved area */
2228 if (is_block_in_log_or_reserved_area 2228 if (is_block_in_log_or_reserved_area
2229 (p_s_sb, real_blocks[i]->b_blocknr)) { 2229 (sb, real_blocks[i]->b_blocknr)) {
2230 reiserfs_warning(p_s_sb, "journal-1204", 2230 reiserfs_warning(sb, "journal-1204",
2231 "REPLAY FAILURE fsck required! " 2231 "REPLAY FAILURE fsck required! "
2232 "Trying to replay onto a log block"); 2232 "Trying to replay onto a log block");
2233 abort_replay: 2233 abort_replay:
@@ -2245,7 +2245,7 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2245 for (i = 0; i < get_desc_trans_len(desc); i++) { 2245 for (i = 0; i < get_desc_trans_len(desc); i++) {
2246 wait_on_buffer(log_blocks[i]); 2246 wait_on_buffer(log_blocks[i]);
2247 if (!buffer_uptodate(log_blocks[i])) { 2247 if (!buffer_uptodate(log_blocks[i])) {
2248 reiserfs_warning(p_s_sb, "journal-1212", 2248 reiserfs_warning(sb, "journal-1212",
2249 "REPLAY FAILURE fsck required! " 2249 "REPLAY FAILURE fsck required! "
2250 "buffer write failed"); 2250 "buffer write failed");
2251 brelse_array(log_blocks + i, 2251 brelse_array(log_blocks + i,
@@ -2270,7 +2270,7 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2270 for (i = 0; i < get_desc_trans_len(desc); i++) { 2270 for (i = 0; i < get_desc_trans_len(desc); i++) {
2271 wait_on_buffer(real_blocks[i]); 2271 wait_on_buffer(real_blocks[i]);
2272 if (!buffer_uptodate(real_blocks[i])) { 2272 if (!buffer_uptodate(real_blocks[i])) {
2273 reiserfs_warning(p_s_sb, "journal-1226", 2273 reiserfs_warning(sb, "journal-1226",
2274 "REPLAY FAILURE, fsck required! " 2274 "REPLAY FAILURE, fsck required! "
2275 "buffer write failed"); 2275 "buffer write failed");
2276 brelse_array(real_blocks + i, 2276 brelse_array(real_blocks + i,
@@ -2284,15 +2284,15 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2284 brelse(real_blocks[i]); 2284 brelse(real_blocks[i]);
2285 } 2285 }
2286 cur_dblock = 2286 cur_dblock =
2287 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2287 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2288 ((trans_offset + get_desc_trans_len(desc) + 2288 ((trans_offset + get_desc_trans_len(desc) +
2289 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)); 2289 2) % SB_ONDISK_JOURNAL_SIZE(sb));
2290 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2290 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2291 "journal-1095: setting journal " "start to offset %ld", 2291 "journal-1095: setting journal " "start to offset %ld",
2292 cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb)); 2292 cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(sb));
2293 2293
2294 /* init starting values for the first transaction, in case this is the last transaction to be replayed. */ 2294 /* init starting values for the first transaction, in case this is the last transaction to be replayed. */
2295 journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); 2295 journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(sb);
2296 journal->j_last_flush_trans_id = trans_id; 2296 journal->j_last_flush_trans_id = trans_id;
2297 journal->j_trans_id = trans_id + 1; 2297 journal->j_trans_id = trans_id + 1;
2298 /* check for trans_id overflow */ 2298 /* check for trans_id overflow */
@@ -2357,9 +2357,9 @@ static struct buffer_head *reiserfs_breada(struct block_device *dev,
2357** 2357**
2358** On exit, it sets things up so the first transaction will work correctly. 2358** On exit, it sets things up so the first transaction will work correctly.
2359*/ 2359*/
2360static int journal_read(struct super_block *p_s_sb) 2360static int journal_read(struct super_block *sb)
2361{ 2361{
2362 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 2362 struct reiserfs_journal *journal = SB_JOURNAL(sb);
2363 struct reiserfs_journal_desc *desc; 2363 struct reiserfs_journal_desc *desc;
2364 unsigned int oldest_trans_id = 0; 2364 unsigned int oldest_trans_id = 0;
2365 unsigned int oldest_invalid_trans_id = 0; 2365 unsigned int oldest_invalid_trans_id = 0;
@@ -2375,8 +2375,8 @@ static int journal_read(struct super_block *p_s_sb)
2375 int ret; 2375 int ret;
2376 char b[BDEVNAME_SIZE]; 2376 char b[BDEVNAME_SIZE];
2377 2377
2378 cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); 2378 cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(sb);
2379 reiserfs_info(p_s_sb, "checking transaction log (%s)\n", 2379 reiserfs_info(sb, "checking transaction log (%s)\n",
2380 bdevname(journal->j_dev_bd, b)); 2380 bdevname(journal->j_dev_bd, b));
2381 start = get_seconds(); 2381 start = get_seconds();
2382 2382
@@ -2384,22 +2384,22 @@ static int journal_read(struct super_block *p_s_sb)
2384 ** is the first unflushed, and if that transaction is not valid, 2384 ** is the first unflushed, and if that transaction is not valid,
2385 ** replay is done 2385 ** replay is done
2386 */ 2386 */
2387 journal->j_header_bh = journal_bread(p_s_sb, 2387 journal->j_header_bh = journal_bread(sb,
2388 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) 2388 SB_ONDISK_JOURNAL_1st_BLOCK(sb)
2389 + SB_ONDISK_JOURNAL_SIZE(p_s_sb)); 2389 + SB_ONDISK_JOURNAL_SIZE(sb));
2390 if (!journal->j_header_bh) { 2390 if (!journal->j_header_bh) {
2391 return 1; 2391 return 1;
2392 } 2392 }
2393 jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data); 2393 jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data);
2394 if (le32_to_cpu(jh->j_first_unflushed_offset) < 2394 if (le32_to_cpu(jh->j_first_unflushed_offset) <
2395 SB_ONDISK_JOURNAL_SIZE(p_s_sb) 2395 SB_ONDISK_JOURNAL_SIZE(sb)
2396 && le32_to_cpu(jh->j_last_flush_trans_id) > 0) { 2396 && le32_to_cpu(jh->j_last_flush_trans_id) > 0) {
2397 oldest_start = 2397 oldest_start =
2398 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2398 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2399 le32_to_cpu(jh->j_first_unflushed_offset); 2399 le32_to_cpu(jh->j_first_unflushed_offset);
2400 oldest_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1; 2400 oldest_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
2401 newest_mount_id = le32_to_cpu(jh->j_mount_id); 2401 newest_mount_id = le32_to_cpu(jh->j_mount_id);
2402 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2402 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2403 "journal-1153: found in " 2403 "journal-1153: found in "
2404 "header: first_unflushed_offset %d, last_flushed_trans_id " 2404 "header: first_unflushed_offset %d, last_flushed_trans_id "
2405 "%lu", le32_to_cpu(jh->j_first_unflushed_offset), 2405 "%lu", le32_to_cpu(jh->j_first_unflushed_offset),
@@ -2411,10 +2411,10 @@ static int journal_read(struct super_block *p_s_sb)
2411 ** through the whole log. 2411 ** through the whole log.
2412 */ 2412 */
2413 d_bh = 2413 d_bh =
2414 journal_bread(p_s_sb, 2414 journal_bread(sb,
2415 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2415 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2416 le32_to_cpu(jh->j_first_unflushed_offset)); 2416 le32_to_cpu(jh->j_first_unflushed_offset));
2417 ret = journal_transaction_is_valid(p_s_sb, d_bh, NULL, NULL); 2417 ret = journal_transaction_is_valid(sb, d_bh, NULL, NULL);
2418 if (!ret) { 2418 if (!ret) {
2419 continue_replay = 0; 2419 continue_replay = 0;
2420 } 2420 }
@@ -2422,8 +2422,8 @@ static int journal_read(struct super_block *p_s_sb)
2422 goto start_log_replay; 2422 goto start_log_replay;
2423 } 2423 }
2424 2424
2425 if (continue_replay && bdev_read_only(p_s_sb->s_bdev)) { 2425 if (continue_replay && bdev_read_only(sb->s_bdev)) {
2426 reiserfs_warning(p_s_sb, "clm-2076", 2426 reiserfs_warning(sb, "clm-2076",
2427 "device is readonly, unable to replay log"); 2427 "device is readonly, unable to replay log");
2428 return -1; 2428 return -1;
2429 } 2429 }
@@ -2433,17 +2433,17 @@ static int journal_read(struct super_block *p_s_sb)
2433 */ 2433 */
2434 while (continue_replay 2434 while (continue_replay
2435 && cur_dblock < 2435 && cur_dblock <
2436 (SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2436 (SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2437 SB_ONDISK_JOURNAL_SIZE(p_s_sb))) { 2437 SB_ONDISK_JOURNAL_SIZE(sb))) {
2438 /* Note that it is required for blocksize of primary fs device and journal 2438 /* Note that it is required for blocksize of primary fs device and journal
2439 device to be the same */ 2439 device to be the same */
2440 d_bh = 2440 d_bh =
2441 reiserfs_breada(journal->j_dev_bd, cur_dblock, 2441 reiserfs_breada(journal->j_dev_bd, cur_dblock,
2442 p_s_sb->s_blocksize, 2442 sb->s_blocksize,
2443 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2443 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2444 SB_ONDISK_JOURNAL_SIZE(p_s_sb)); 2444 SB_ONDISK_JOURNAL_SIZE(sb));
2445 ret = 2445 ret =
2446 journal_transaction_is_valid(p_s_sb, d_bh, 2446 journal_transaction_is_valid(sb, d_bh,
2447 &oldest_invalid_trans_id, 2447 &oldest_invalid_trans_id,
2448 &newest_mount_id); 2448 &newest_mount_id);
2449 if (ret == 1) { 2449 if (ret == 1) {
@@ -2452,26 +2452,26 @@ static int journal_read(struct super_block *p_s_sb)
2452 oldest_trans_id = get_desc_trans_id(desc); 2452 oldest_trans_id = get_desc_trans_id(desc);
2453 oldest_start = d_bh->b_blocknr; 2453 oldest_start = d_bh->b_blocknr;
2454 newest_mount_id = get_desc_mount_id(desc); 2454 newest_mount_id = get_desc_mount_id(desc);
2455 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2455 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2456 "journal-1179: Setting " 2456 "journal-1179: Setting "
2457 "oldest_start to offset %llu, trans_id %lu", 2457 "oldest_start to offset %llu, trans_id %lu",
2458 oldest_start - 2458 oldest_start -
2459 SB_ONDISK_JOURNAL_1st_BLOCK 2459 SB_ONDISK_JOURNAL_1st_BLOCK
2460 (p_s_sb), oldest_trans_id); 2460 (sb), oldest_trans_id);
2461 } else if (oldest_trans_id > get_desc_trans_id(desc)) { 2461 } else if (oldest_trans_id > get_desc_trans_id(desc)) {
2462 /* one we just read was older */ 2462 /* one we just read was older */
2463 oldest_trans_id = get_desc_trans_id(desc); 2463 oldest_trans_id = get_desc_trans_id(desc);
2464 oldest_start = d_bh->b_blocknr; 2464 oldest_start = d_bh->b_blocknr;
2465 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2465 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2466 "journal-1180: Resetting " 2466 "journal-1180: Resetting "
2467 "oldest_start to offset %lu, trans_id %lu", 2467 "oldest_start to offset %lu, trans_id %lu",
2468 oldest_start - 2468 oldest_start -
2469 SB_ONDISK_JOURNAL_1st_BLOCK 2469 SB_ONDISK_JOURNAL_1st_BLOCK
2470 (p_s_sb), oldest_trans_id); 2470 (sb), oldest_trans_id);
2471 } 2471 }
2472 if (newest_mount_id < get_desc_mount_id(desc)) { 2472 if (newest_mount_id < get_desc_mount_id(desc)) {
2473 newest_mount_id = get_desc_mount_id(desc); 2473 newest_mount_id = get_desc_mount_id(desc);
2474 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2474 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2475 "journal-1299: Setting " 2475 "journal-1299: Setting "
2476 "newest_mount_id to %d", 2476 "newest_mount_id to %d",
2477 get_desc_mount_id(desc)); 2477 get_desc_mount_id(desc));
@@ -2486,17 +2486,17 @@ static int journal_read(struct super_block *p_s_sb)
2486 start_log_replay: 2486 start_log_replay:
2487 cur_dblock = oldest_start; 2487 cur_dblock = oldest_start;
2488 if (oldest_trans_id) { 2488 if (oldest_trans_id) {
2489 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2489 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2490 "journal-1206: Starting replay " 2490 "journal-1206: Starting replay "
2491 "from offset %llu, trans_id %lu", 2491 "from offset %llu, trans_id %lu",
2492 cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), 2492 cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2493 oldest_trans_id); 2493 oldest_trans_id);
2494 2494
2495 } 2495 }
2496 replay_count = 0; 2496 replay_count = 0;
2497 while (continue_replay && oldest_trans_id > 0) { 2497 while (continue_replay && oldest_trans_id > 0) {
2498 ret = 2498 ret =
2499 journal_read_transaction(p_s_sb, cur_dblock, oldest_start, 2499 journal_read_transaction(sb, cur_dblock, oldest_start,
2500 oldest_trans_id, newest_mount_id); 2500 oldest_trans_id, newest_mount_id);
2501 if (ret < 0) { 2501 if (ret < 0) {
2502 return ret; 2502 return ret;
@@ -2504,14 +2504,14 @@ static int journal_read(struct super_block *p_s_sb)
2504 break; 2504 break;
2505 } 2505 }
2506 cur_dblock = 2506 cur_dblock =
2507 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + journal->j_start; 2507 SB_ONDISK_JOURNAL_1st_BLOCK(sb) + journal->j_start;
2508 replay_count++; 2508 replay_count++;
2509 if (cur_dblock == oldest_start) 2509 if (cur_dblock == oldest_start)
2510 break; 2510 break;
2511 } 2511 }
2512 2512
2513 if (oldest_trans_id == 0) { 2513 if (oldest_trans_id == 0) {
2514 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, 2514 reiserfs_debug(sb, REISERFS_DEBUG_CODE,
2515 "journal-1225: No valid " "transactions found"); 2515 "journal-1225: No valid " "transactions found");
2516 } 2516 }
2517 /* j_start does not get set correctly if we don't replay any transactions. 2517 /* j_start does not get set correctly if we don't replay any transactions.
@@ -2531,16 +2531,16 @@ static int journal_read(struct super_block *p_s_sb)
2531 } else { 2531 } else {
2532 journal->j_mount_id = newest_mount_id + 1; 2532 journal->j_mount_id = newest_mount_id + 1;
2533 } 2533 }
2534 reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1299: Setting " 2534 reiserfs_debug(sb, REISERFS_DEBUG_CODE, "journal-1299: Setting "
2535 "newest_mount_id to %lu", journal->j_mount_id); 2535 "newest_mount_id to %lu", journal->j_mount_id);
2536 journal->j_first_unflushed_offset = journal->j_start; 2536 journal->j_first_unflushed_offset = journal->j_start;
2537 if (replay_count > 0) { 2537 if (replay_count > 0) {
2538 reiserfs_info(p_s_sb, 2538 reiserfs_info(sb,
2539 "replayed %d transactions in %lu seconds\n", 2539 "replayed %d transactions in %lu seconds\n",
2540 replay_count, get_seconds() - start); 2540 replay_count, get_seconds() - start);
2541 } 2541 }
2542 if (!bdev_read_only(p_s_sb->s_bdev) && 2542 if (!bdev_read_only(sb->s_bdev) &&
2543 _update_journal_header_block(p_s_sb, journal->j_start, 2543 _update_journal_header_block(sb, journal->j_start,
2544 journal->j_last_flush_trans_id)) { 2544 journal->j_last_flush_trans_id)) {
2545 /* replay failed, caller must call free_journal_ram and abort 2545 /* replay failed, caller must call free_journal_ram and abort
2546 ** the mount 2546 ** the mount
@@ -2565,9 +2565,9 @@ static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s)
2565 return jl; 2565 return jl;
2566} 2566}
2567 2567
2568static void journal_list_init(struct super_block *p_s_sb) 2568static void journal_list_init(struct super_block *sb)
2569{ 2569{
2570 SB_JOURNAL(p_s_sb)->j_current_jl = alloc_journal_list(p_s_sb); 2570 SB_JOURNAL(sb)->j_current_jl = alloc_journal_list(sb);
2571} 2571}
2572 2572
2573static int release_journal_dev(struct super_block *super, 2573static int release_journal_dev(struct super_block *super,
@@ -2666,28 +2666,28 @@ static int journal_init_dev(struct super_block *super,
2666 */ 2666 */
2667#define REISERFS_STANDARD_BLKSIZE (4096) 2667#define REISERFS_STANDARD_BLKSIZE (4096)
2668 2668
2669static int check_advise_trans_params(struct super_block *p_s_sb, 2669static int check_advise_trans_params(struct super_block *sb,
2670 struct reiserfs_journal *journal) 2670 struct reiserfs_journal *journal)
2671{ 2671{
2672 if (journal->j_trans_max) { 2672 if (journal->j_trans_max) {
2673 /* Non-default journal params. 2673 /* Non-default journal params.
2674 Do sanity check for them. */ 2674 Do sanity check for them. */
2675 int ratio = 1; 2675 int ratio = 1;
2676 if (p_s_sb->s_blocksize < REISERFS_STANDARD_BLKSIZE) 2676 if (sb->s_blocksize < REISERFS_STANDARD_BLKSIZE)
2677 ratio = REISERFS_STANDARD_BLKSIZE / p_s_sb->s_blocksize; 2677 ratio = REISERFS_STANDARD_BLKSIZE / sb->s_blocksize;
2678 2678
2679 if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio || 2679 if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio ||
2680 journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio || 2680 journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio ||
2681 SB_ONDISK_JOURNAL_SIZE(p_s_sb) / journal->j_trans_max < 2681 SB_ONDISK_JOURNAL_SIZE(sb) / journal->j_trans_max <
2682 JOURNAL_MIN_RATIO) { 2682 JOURNAL_MIN_RATIO) {
2683 reiserfs_warning(p_s_sb, "sh-462", 2683 reiserfs_warning(sb, "sh-462",
2684 "bad transaction max size (%u). " 2684 "bad transaction max size (%u). "
2685 "FSCK?", journal->j_trans_max); 2685 "FSCK?", journal->j_trans_max);
2686 return 1; 2686 return 1;
2687 } 2687 }
2688 if (journal->j_max_batch != (journal->j_trans_max) * 2688 if (journal->j_max_batch != (journal->j_trans_max) *
2689 JOURNAL_MAX_BATCH_DEFAULT/JOURNAL_TRANS_MAX_DEFAULT) { 2689 JOURNAL_MAX_BATCH_DEFAULT/JOURNAL_TRANS_MAX_DEFAULT) {
2690 reiserfs_warning(p_s_sb, "sh-463", 2690 reiserfs_warning(sb, "sh-463",
2691 "bad transaction max batch (%u). " 2691 "bad transaction max batch (%u). "
2692 "FSCK?", journal->j_max_batch); 2692 "FSCK?", journal->j_max_batch);
2693 return 1; 2693 return 1;
@@ -2697,9 +2697,9 @@ static int check_advise_trans_params(struct super_block *p_s_sb,
2697 The file system was created by old version 2697 The file system was created by old version
2698 of mkreiserfs, so some fields contain zeros, 2698 of mkreiserfs, so some fields contain zeros,
2699 and we need to advise proper values for them */ 2699 and we need to advise proper values for them */
2700 if (p_s_sb->s_blocksize != REISERFS_STANDARD_BLKSIZE) { 2700 if (sb->s_blocksize != REISERFS_STANDARD_BLKSIZE) {
2701 reiserfs_warning(p_s_sb, "sh-464", "bad blocksize (%u)", 2701 reiserfs_warning(sb, "sh-464", "bad blocksize (%u)",
2702 p_s_sb->s_blocksize); 2702 sb->s_blocksize);
2703 return 1; 2703 return 1;
2704 } 2704 }
2705 journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT; 2705 journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT;
@@ -2712,10 +2712,10 @@ static int check_advise_trans_params(struct super_block *p_s_sb,
2712/* 2712/*
2713** must be called once on fs mount. calls journal_read for you 2713** must be called once on fs mount. calls journal_read for you
2714*/ 2714*/
2715int journal_init(struct super_block *p_s_sb, const char *j_dev_name, 2715int journal_init(struct super_block *sb, const char *j_dev_name,
2716 int old_format, unsigned int commit_max_age) 2716 int old_format, unsigned int commit_max_age)
2717{ 2717{
2718 int num_cnodes = SB_ONDISK_JOURNAL_SIZE(p_s_sb) * 2; 2718 int num_cnodes = SB_ONDISK_JOURNAL_SIZE(sb) * 2;
2719 struct buffer_head *bhjh; 2719 struct buffer_head *bhjh;
2720 struct reiserfs_super_block *rs; 2720 struct reiserfs_super_block *rs;
2721 struct reiserfs_journal_header *jh; 2721 struct reiserfs_journal_header *jh;
@@ -2723,9 +2723,9 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2723 struct reiserfs_journal_list *jl; 2723 struct reiserfs_journal_list *jl;
2724 char b[BDEVNAME_SIZE]; 2724 char b[BDEVNAME_SIZE];
2725 2725
2726 journal = SB_JOURNAL(p_s_sb) = vmalloc(sizeof(struct reiserfs_journal)); 2726 journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal));
2727 if (!journal) { 2727 if (!journal) {
2728 reiserfs_warning(p_s_sb, "journal-1256", 2728 reiserfs_warning(sb, "journal-1256",
2729 "unable to get memory for journal structure"); 2729 "unable to get memory for journal structure");
2730 return 1; 2730 return 1;
2731 } 2731 }
@@ -2735,50 +2735,50 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2735 INIT_LIST_HEAD(&journal->j_working_list); 2735 INIT_LIST_HEAD(&journal->j_working_list);
2736 INIT_LIST_HEAD(&journal->j_journal_list); 2736 INIT_LIST_HEAD(&journal->j_journal_list);
2737 journal->j_persistent_trans = 0; 2737 journal->j_persistent_trans = 0;
2738 if (reiserfs_allocate_list_bitmaps(p_s_sb, 2738 if (reiserfs_allocate_list_bitmaps(sb,
2739 journal->j_list_bitmap, 2739 journal->j_list_bitmap,
2740 reiserfs_bmap_count(p_s_sb))) 2740 reiserfs_bmap_count(sb)))
2741 goto free_and_return; 2741 goto free_and_return;
2742 allocate_bitmap_nodes(p_s_sb); 2742 allocate_bitmap_nodes(sb);
2743 2743
2744 /* reserved for journal area support */ 2744 /* reserved for journal area support */
2745 SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) = (old_format ? 2745 SB_JOURNAL_1st_RESERVED_BLOCK(sb) = (old_format ?
2746 REISERFS_OLD_DISK_OFFSET_IN_BYTES 2746 REISERFS_OLD_DISK_OFFSET_IN_BYTES
2747 / p_s_sb->s_blocksize + 2747 / sb->s_blocksize +
2748 reiserfs_bmap_count(p_s_sb) + 2748 reiserfs_bmap_count(sb) +
2749 1 : 2749 1 :
2750 REISERFS_DISK_OFFSET_IN_BYTES / 2750 REISERFS_DISK_OFFSET_IN_BYTES /
2751 p_s_sb->s_blocksize + 2); 2751 sb->s_blocksize + 2);
2752 2752
2753 /* Sanity check to see is the standard journal fitting withing first bitmap 2753 /* Sanity check to see is the standard journal fitting withing first bitmap
2754 (actual for small blocksizes) */ 2754 (actual for small blocksizes) */
2755 if (!SB_ONDISK_JOURNAL_DEVICE(p_s_sb) && 2755 if (!SB_ONDISK_JOURNAL_DEVICE(sb) &&
2756 (SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) + 2756 (SB_JOURNAL_1st_RESERVED_BLOCK(sb) +
2757 SB_ONDISK_JOURNAL_SIZE(p_s_sb) > p_s_sb->s_blocksize * 8)) { 2757 SB_ONDISK_JOURNAL_SIZE(sb) > sb->s_blocksize * 8)) {
2758 reiserfs_warning(p_s_sb, "journal-1393", 2758 reiserfs_warning(sb, "journal-1393",
2759 "journal does not fit for area addressed " 2759 "journal does not fit for area addressed "
2760 "by first of bitmap blocks. It starts at " 2760 "by first of bitmap blocks. It starts at "
2761 "%u and its size is %u. Block size %ld", 2761 "%u and its size is %u. Block size %ld",
2762 SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb), 2762 SB_JOURNAL_1st_RESERVED_BLOCK(sb),
2763 SB_ONDISK_JOURNAL_SIZE(p_s_sb), 2763 SB_ONDISK_JOURNAL_SIZE(sb),
2764 p_s_sb->s_blocksize); 2764 sb->s_blocksize);
2765 goto free_and_return; 2765 goto free_and_return;
2766 } 2766 }
2767 2767
2768 if (journal_init_dev(p_s_sb, journal, j_dev_name) != 0) { 2768 if (journal_init_dev(sb, journal, j_dev_name) != 0) {
2769 reiserfs_warning(p_s_sb, "sh-462", 2769 reiserfs_warning(sb, "sh-462",
2770 "unable to initialize jornal device"); 2770 "unable to initialize jornal device");
2771 goto free_and_return; 2771 goto free_and_return;
2772 } 2772 }
2773 2773
2774 rs = SB_DISK_SUPER_BLOCK(p_s_sb); 2774 rs = SB_DISK_SUPER_BLOCK(sb);
2775 2775
2776 /* read journal header */ 2776 /* read journal header */
2777 bhjh = journal_bread(p_s_sb, 2777 bhjh = journal_bread(sb,
2778 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 2778 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
2779 SB_ONDISK_JOURNAL_SIZE(p_s_sb)); 2779 SB_ONDISK_JOURNAL_SIZE(sb));
2780 if (!bhjh) { 2780 if (!bhjh) {
2781 reiserfs_warning(p_s_sb, "sh-459", 2781 reiserfs_warning(sb, "sh-459",
2782 "unable to read journal header"); 2782 "unable to read journal header");
2783 goto free_and_return; 2783 goto free_and_return;
2784 } 2784 }
@@ -2788,7 +2788,7 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2788 if (is_reiserfs_jr(rs) 2788 if (is_reiserfs_jr(rs)
2789 && (le32_to_cpu(jh->jh_journal.jp_journal_magic) != 2789 && (le32_to_cpu(jh->jh_journal.jp_journal_magic) !=
2790 sb_jp_journal_magic(rs))) { 2790 sb_jp_journal_magic(rs))) {
2791 reiserfs_warning(p_s_sb, "sh-460", 2791 reiserfs_warning(sb, "sh-460",
2792 "journal header magic %x (device %s) does " 2792 "journal header magic %x (device %s) does "
2793 "not match to magic found in super block %x", 2793 "not match to magic found in super block %x",
2794 jh->jh_journal.jp_journal_magic, 2794 jh->jh_journal.jp_journal_magic,
@@ -2804,7 +2804,7 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2804 le32_to_cpu(jh->jh_journal.jp_journal_max_commit_age); 2804 le32_to_cpu(jh->jh_journal.jp_journal_max_commit_age);
2805 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE; 2805 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
2806 2806
2807 if (check_advise_trans_params(p_s_sb, journal) != 0) 2807 if (check_advise_trans_params(sb, journal) != 0)
2808 goto free_and_return; 2808 goto free_and_return;
2809 journal->j_default_max_commit_age = journal->j_max_commit_age; 2809 journal->j_default_max_commit_age = journal->j_max_commit_age;
2810 2810
@@ -2813,12 +2813,12 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2813 journal->j_max_trans_age = commit_max_age; 2813 journal->j_max_trans_age = commit_max_age;
2814 } 2814 }
2815 2815
2816 reiserfs_info(p_s_sb, "journal params: device %s, size %u, " 2816 reiserfs_info(sb, "journal params: device %s, size %u, "
2817 "journal first block %u, max trans len %u, max batch %u, " 2817 "journal first block %u, max trans len %u, max batch %u, "
2818 "max commit age %u, max trans age %u\n", 2818 "max commit age %u, max trans age %u\n",
2819 bdevname(journal->j_dev_bd, b), 2819 bdevname(journal->j_dev_bd, b),
2820 SB_ONDISK_JOURNAL_SIZE(p_s_sb), 2820 SB_ONDISK_JOURNAL_SIZE(sb),
2821 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb), 2821 SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2822 journal->j_trans_max, 2822 journal->j_trans_max,
2823 journal->j_max_batch, 2823 journal->j_max_batch,
2824 journal->j_max_commit_age, journal->j_max_trans_age); 2824 journal->j_max_commit_age, journal->j_max_trans_age);
@@ -2826,7 +2826,7 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2826 brelse(bhjh); 2826 brelse(bhjh);
2827 2827
2828 journal->j_list_bitmap_index = 0; 2828 journal->j_list_bitmap_index = 0;
2829 journal_list_init(p_s_sb); 2829 journal_list_init(sb);
2830 2830
2831 memset(journal->j_list_hash_table, 0, 2831 memset(journal->j_list_hash_table, 0,
2832 JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)); 2832 JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *));
@@ -2858,7 +2858,7 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2858 journal->j_must_wait = 0; 2858 journal->j_must_wait = 0;
2859 2859
2860 if (journal->j_cnode_free == 0) { 2860 if (journal->j_cnode_free == 0) {
2861 reiserfs_warning(p_s_sb, "journal-2004", "Journal cnode memory " 2861 reiserfs_warning(sb, "journal-2004", "Journal cnode memory "
2862 "allocation failed (%ld bytes). Journal is " 2862 "allocation failed (%ld bytes). Journal is "
2863 "too large for available memory. Usually " 2863 "too large for available memory. Usually "
2864 "this is due to a journal that is too large.", 2864 "this is due to a journal that is too large.",
@@ -2866,16 +2866,16 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2866 goto free_and_return; 2866 goto free_and_return;
2867 } 2867 }
2868 2868
2869 init_journal_hash(p_s_sb); 2869 init_journal_hash(sb);
2870 jl = journal->j_current_jl; 2870 jl = journal->j_current_jl;
2871 jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl); 2871 jl->j_list_bitmap = get_list_bitmap(sb, jl);
2872 if (!jl->j_list_bitmap) { 2872 if (!jl->j_list_bitmap) {
2873 reiserfs_warning(p_s_sb, "journal-2005", 2873 reiserfs_warning(sb, "journal-2005",
2874 "get_list_bitmap failed for journal list 0"); 2874 "get_list_bitmap failed for journal list 0");
2875 goto free_and_return; 2875 goto free_and_return;
2876 } 2876 }
2877 if (journal_read(p_s_sb) < 0) { 2877 if (journal_read(sb) < 0) {
2878 reiserfs_warning(p_s_sb, "reiserfs-2006", 2878 reiserfs_warning(sb, "reiserfs-2006",
2879 "Replay Failure, unable to mount"); 2879 "Replay Failure, unable to mount");
2880 goto free_and_return; 2880 goto free_and_return;
2881 } 2881 }
@@ -2885,10 +2885,10 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2885 commit_wq = create_workqueue("reiserfs"); 2885 commit_wq = create_workqueue("reiserfs");
2886 2886
2887 INIT_DELAYED_WORK(&journal->j_work, flush_async_commits); 2887 INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
2888 journal->j_work_sb = p_s_sb; 2888 journal->j_work_sb = sb;
2889 return 0; 2889 return 0;
2890 free_and_return: 2890 free_and_return:
2891 free_journal_ram(p_s_sb); 2891 free_journal_ram(sb);
2892 return 1; 2892 return 1;
2893} 2893}
2894 2894
@@ -3004,37 +3004,37 @@ static void let_transaction_grow(struct super_block *sb, unsigned int trans_id)
3004** expect to use in nblocks. 3004** expect to use in nblocks.
3005*/ 3005*/
3006static int do_journal_begin_r(struct reiserfs_transaction_handle *th, 3006static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3007 struct super_block *p_s_sb, unsigned long nblocks, 3007 struct super_block *sb, unsigned long nblocks,
3008 int join) 3008 int join)
3009{ 3009{
3010 time_t now = get_seconds(); 3010 time_t now = get_seconds();
3011 unsigned int old_trans_id; 3011 unsigned int old_trans_id;
3012 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3012 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3013 struct reiserfs_transaction_handle myth; 3013 struct reiserfs_transaction_handle myth;
3014 int sched_count = 0; 3014 int sched_count = 0;
3015 int retval; 3015 int retval;
3016 3016
3017 reiserfs_check_lock_depth(p_s_sb, "journal_begin"); 3017 reiserfs_check_lock_depth(sb, "journal_begin");
3018 BUG_ON(nblocks > journal->j_trans_max); 3018 BUG_ON(nblocks > journal->j_trans_max);
3019 3019
3020 PROC_INFO_INC(p_s_sb, journal.journal_being); 3020 PROC_INFO_INC(sb, journal.journal_being);
3021 /* set here for journal_join */ 3021 /* set here for journal_join */
3022 th->t_refcount = 1; 3022 th->t_refcount = 1;
3023 th->t_super = p_s_sb; 3023 th->t_super = sb;
3024 3024
3025 relock: 3025 relock:
3026 lock_journal(p_s_sb); 3026 lock_journal(sb);
3027 if (join != JBEGIN_ABORT && reiserfs_is_journal_aborted(journal)) { 3027 if (join != JBEGIN_ABORT && reiserfs_is_journal_aborted(journal)) {
3028 unlock_journal(p_s_sb); 3028 unlock_journal(sb);
3029 retval = journal->j_errno; 3029 retval = journal->j_errno;
3030 goto out_fail; 3030 goto out_fail;
3031 } 3031 }
3032 journal->j_bcount++; 3032 journal->j_bcount++;
3033 3033
3034 if (test_bit(J_WRITERS_BLOCKED, &journal->j_state)) { 3034 if (test_bit(J_WRITERS_BLOCKED, &journal->j_state)) {
3035 unlock_journal(p_s_sb); 3035 unlock_journal(sb);
3036 reiserfs_wait_on_write_block(p_s_sb); 3036 reiserfs_wait_on_write_block(sb);
3037 PROC_INFO_INC(p_s_sb, journal.journal_relock_writers); 3037 PROC_INFO_INC(sb, journal.journal_relock_writers);
3038 goto relock; 3038 goto relock;
3039 } 3039 }
3040 now = get_seconds(); 3040 now = get_seconds();
@@ -3055,7 +3055,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3055 || (!join && journal->j_cnode_free < (journal->j_trans_max * 3))) { 3055 || (!join && journal->j_cnode_free < (journal->j_trans_max * 3))) {
3056 3056
3057 old_trans_id = journal->j_trans_id; 3057 old_trans_id = journal->j_trans_id;
3058 unlock_journal(p_s_sb); /* allow others to finish this transaction */ 3058 unlock_journal(sb); /* allow others to finish this transaction */
3059 3059
3060 if (!join && (journal->j_len_alloc + nblocks + 2) >= 3060 if (!join && (journal->j_len_alloc + nblocks + 2) >=
3061 journal->j_max_batch && 3061 journal->j_max_batch &&
@@ -3063,7 +3063,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3063 (journal->j_len_alloc * 75)) { 3063 (journal->j_len_alloc * 75)) {
3064 if (atomic_read(&journal->j_wcount) > 10) { 3064 if (atomic_read(&journal->j_wcount) > 10) {
3065 sched_count++; 3065 sched_count++;
3066 queue_log_writer(p_s_sb); 3066 queue_log_writer(sb);
3067 goto relock; 3067 goto relock;
3068 } 3068 }
3069 } 3069 }
@@ -3073,25 +3073,25 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3073 if (atomic_read(&journal->j_jlock)) { 3073 if (atomic_read(&journal->j_jlock)) {
3074 while (journal->j_trans_id == old_trans_id && 3074 while (journal->j_trans_id == old_trans_id &&
3075 atomic_read(&journal->j_jlock)) { 3075 atomic_read(&journal->j_jlock)) {
3076 queue_log_writer(p_s_sb); 3076 queue_log_writer(sb);
3077 } 3077 }
3078 goto relock; 3078 goto relock;
3079 } 3079 }
3080 retval = journal_join(&myth, p_s_sb, 1); 3080 retval = journal_join(&myth, sb, 1);
3081 if (retval) 3081 if (retval)
3082 goto out_fail; 3082 goto out_fail;
3083 3083
3084 /* someone might have ended the transaction while we joined */ 3084 /* someone might have ended the transaction while we joined */
3085 if (old_trans_id != journal->j_trans_id) { 3085 if (old_trans_id != journal->j_trans_id) {
3086 retval = do_journal_end(&myth, p_s_sb, 1, 0); 3086 retval = do_journal_end(&myth, sb, 1, 0);
3087 } else { 3087 } else {
3088 retval = do_journal_end(&myth, p_s_sb, 1, COMMIT_NOW); 3088 retval = do_journal_end(&myth, sb, 1, COMMIT_NOW);
3089 } 3089 }
3090 3090
3091 if (retval) 3091 if (retval)
3092 goto out_fail; 3092 goto out_fail;
3093 3093
3094 PROC_INFO_INC(p_s_sb, journal.journal_relock_wcount); 3094 PROC_INFO_INC(sb, journal.journal_relock_wcount);
3095 goto relock; 3095 goto relock;
3096 } 3096 }
3097 /* we are the first writer, set trans_id */ 3097 /* we are the first writer, set trans_id */
@@ -3103,7 +3103,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3103 th->t_blocks_logged = 0; 3103 th->t_blocks_logged = 0;
3104 th->t_blocks_allocated = nblocks; 3104 th->t_blocks_allocated = nblocks;
3105 th->t_trans_id = journal->j_trans_id; 3105 th->t_trans_id = journal->j_trans_id;
3106 unlock_journal(p_s_sb); 3106 unlock_journal(sb);
3107 INIT_LIST_HEAD(&th->t_list); 3107 INIT_LIST_HEAD(&th->t_list);
3108 get_fs_excl(); 3108 get_fs_excl();
3109 return 0; 3109 return 0;
@@ -3113,7 +3113,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3113 /* Re-set th->t_super, so we can properly keep track of how many 3113 /* Re-set th->t_super, so we can properly keep track of how many
3114 * persistent transactions there are. We need to do this so if this 3114 * persistent transactions there are. We need to do this so if this
3115 * call is part of a failed restart_transaction, we can free it later */ 3115 * call is part of a failed restart_transaction, we can free it later */
3116 th->t_super = p_s_sb; 3116 th->t_super = sb;
3117 return retval; 3117 return retval;
3118} 3118}
3119 3119
@@ -3164,7 +3164,7 @@ int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *th)
3164} 3164}
3165 3165
3166static int journal_join(struct reiserfs_transaction_handle *th, 3166static int journal_join(struct reiserfs_transaction_handle *th,
3167 struct super_block *p_s_sb, unsigned long nblocks) 3167 struct super_block *sb, unsigned long nblocks)
3168{ 3168{
3169 struct reiserfs_transaction_handle *cur_th = current->journal_info; 3169 struct reiserfs_transaction_handle *cur_th = current->journal_info;
3170 3170
@@ -3173,11 +3173,11 @@ static int journal_join(struct reiserfs_transaction_handle *th,
3173 */ 3173 */
3174 th->t_handle_save = cur_th; 3174 th->t_handle_save = cur_th;
3175 BUG_ON(cur_th && cur_th->t_refcount > 1); 3175 BUG_ON(cur_th && cur_th->t_refcount > 1);
3176 return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_JOIN); 3176 return do_journal_begin_r(th, sb, nblocks, JBEGIN_JOIN);
3177} 3177}
3178 3178
3179int journal_join_abort(struct reiserfs_transaction_handle *th, 3179int journal_join_abort(struct reiserfs_transaction_handle *th,
3180 struct super_block *p_s_sb, unsigned long nblocks) 3180 struct super_block *sb, unsigned long nblocks)
3181{ 3181{
3182 struct reiserfs_transaction_handle *cur_th = current->journal_info; 3182 struct reiserfs_transaction_handle *cur_th = current->journal_info;
3183 3183
@@ -3186,11 +3186,11 @@ int journal_join_abort(struct reiserfs_transaction_handle *th,
3186 */ 3186 */
3187 th->t_handle_save = cur_th; 3187 th->t_handle_save = cur_th;
3188 BUG_ON(cur_th && cur_th->t_refcount > 1); 3188 BUG_ON(cur_th && cur_th->t_refcount > 1);
3189 return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_ABORT); 3189 return do_journal_begin_r(th, sb, nblocks, JBEGIN_ABORT);
3190} 3190}
3191 3191
3192int journal_begin(struct reiserfs_transaction_handle *th, 3192int journal_begin(struct reiserfs_transaction_handle *th,
3193 struct super_block *p_s_sb, unsigned long nblocks) 3193 struct super_block *sb, unsigned long nblocks)
3194{ 3194{
3195 struct reiserfs_transaction_handle *cur_th = current->journal_info; 3195 struct reiserfs_transaction_handle *cur_th = current->journal_info;
3196 int ret; 3196 int ret;
@@ -3198,12 +3198,12 @@ int journal_begin(struct reiserfs_transaction_handle *th,
3198 th->t_handle_save = NULL; 3198 th->t_handle_save = NULL;
3199 if (cur_th) { 3199 if (cur_th) {
3200 /* we are nesting into the current transaction */ 3200 /* we are nesting into the current transaction */
3201 if (cur_th->t_super == p_s_sb) { 3201 if (cur_th->t_super == sb) {
3202 BUG_ON(!cur_th->t_refcount); 3202 BUG_ON(!cur_th->t_refcount);
3203 cur_th->t_refcount++; 3203 cur_th->t_refcount++;
3204 memcpy(th, cur_th, sizeof(*th)); 3204 memcpy(th, cur_th, sizeof(*th));
3205 if (th->t_refcount <= 1) 3205 if (th->t_refcount <= 1)
3206 reiserfs_warning(p_s_sb, "reiserfs-2005", 3206 reiserfs_warning(sb, "reiserfs-2005",
3207 "BAD: refcount <= 1, but " 3207 "BAD: refcount <= 1, but "
3208 "journal_info != 0"); 3208 "journal_info != 0");
3209 return 0; 3209 return 0;
@@ -3212,7 +3212,7 @@ int journal_begin(struct reiserfs_transaction_handle *th,
3212 ** save it and restore on journal_end. This should never 3212 ** save it and restore on journal_end. This should never
3213 ** really happen... 3213 ** really happen...
3214 */ 3214 */
3215 reiserfs_warning(p_s_sb, "clm-2100", 3215 reiserfs_warning(sb, "clm-2100",
3216 "nesting info a different FS"); 3216 "nesting info a different FS");
3217 th->t_handle_save = current->journal_info; 3217 th->t_handle_save = current->journal_info;
3218 current->journal_info = th; 3218 current->journal_info = th;
@@ -3220,7 +3220,7 @@ int journal_begin(struct reiserfs_transaction_handle *th,
3220 } else { 3220 } else {
3221 current->journal_info = th; 3221 current->journal_info = th;
3222 } 3222 }
3223 ret = do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_REG); 3223 ret = do_journal_begin_r(th, sb, nblocks, JBEGIN_REG);
3224 BUG_ON(current->journal_info != th); 3224 BUG_ON(current->journal_info != th);
3225 3225
3226 /* I guess this boils down to being the reciprocal of clm-2100 above. 3226 /* I guess this boils down to being the reciprocal of clm-2100 above.
@@ -3244,28 +3244,28 @@ int journal_begin(struct reiserfs_transaction_handle *th,
3244** if j_len, is bigger than j_len_alloc, it pushes j_len_alloc to 10 + j_len. 3244** if j_len, is bigger than j_len_alloc, it pushes j_len_alloc to 10 + j_len.
3245*/ 3245*/
3246int journal_mark_dirty(struct reiserfs_transaction_handle *th, 3246int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3247 struct super_block *p_s_sb, struct buffer_head *bh) 3247 struct super_block *sb, struct buffer_head *bh)
3248{ 3248{
3249 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3249 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3250 struct reiserfs_journal_cnode *cn = NULL; 3250 struct reiserfs_journal_cnode *cn = NULL;
3251 int count_already_incd = 0; 3251 int count_already_incd = 0;
3252 int prepared = 0; 3252 int prepared = 0;
3253 BUG_ON(!th->t_trans_id); 3253 BUG_ON(!th->t_trans_id);
3254 3254
3255 PROC_INFO_INC(p_s_sb, journal.mark_dirty); 3255 PROC_INFO_INC(sb, journal.mark_dirty);
3256 if (th->t_trans_id != journal->j_trans_id) { 3256 if (th->t_trans_id != journal->j_trans_id) {
3257 reiserfs_panic(th->t_super, "journal-1577", 3257 reiserfs_panic(th->t_super, "journal-1577",
3258 "handle trans id %ld != current trans id %ld", 3258 "handle trans id %ld != current trans id %ld",
3259 th->t_trans_id, journal->j_trans_id); 3259 th->t_trans_id, journal->j_trans_id);
3260 } 3260 }
3261 3261
3262 p_s_sb->s_dirt = 1; 3262 sb->s_dirt = 1;
3263 3263
3264 prepared = test_clear_buffer_journal_prepared(bh); 3264 prepared = test_clear_buffer_journal_prepared(bh);
3265 clear_buffer_journal_restore_dirty(bh); 3265 clear_buffer_journal_restore_dirty(bh);
3266 /* already in this transaction, we are done */ 3266 /* already in this transaction, we are done */
3267 if (buffer_journaled(bh)) { 3267 if (buffer_journaled(bh)) {
3268 PROC_INFO_INC(p_s_sb, journal.mark_dirty_already); 3268 PROC_INFO_INC(sb, journal.mark_dirty_already);
3269 return 0; 3269 return 0;
3270 } 3270 }
3271 3271
@@ -3274,7 +3274,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3274 ** could get to disk too early. NOT GOOD. 3274 ** could get to disk too early. NOT GOOD.
3275 */ 3275 */
3276 if (!prepared || buffer_dirty(bh)) { 3276 if (!prepared || buffer_dirty(bh)) {
3277 reiserfs_warning(p_s_sb, "journal-1777", 3277 reiserfs_warning(sb, "journal-1777",
3278 "buffer %llu bad state " 3278 "buffer %llu bad state "
3279 "%cPREPARED %cLOCKED %cDIRTY %cJDIRTY_WAIT", 3279 "%cPREPARED %cLOCKED %cDIRTY %cJDIRTY_WAIT",
3280 (unsigned long long)bh->b_blocknr, 3280 (unsigned long long)bh->b_blocknr,
@@ -3285,7 +3285,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3285 } 3285 }
3286 3286
3287 if (atomic_read(&(journal->j_wcount)) <= 0) { 3287 if (atomic_read(&(journal->j_wcount)) <= 0) {
3288 reiserfs_warning(p_s_sb, "journal-1409", 3288 reiserfs_warning(sb, "journal-1409",
3289 "returning because j_wcount was %d", 3289 "returning because j_wcount was %d",
3290 atomic_read(&(journal->j_wcount))); 3290 atomic_read(&(journal->j_wcount)));
3291 return 1; 3291 return 1;
@@ -3301,7 +3301,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3301 3301
3302 if (buffer_journal_dirty(bh)) { 3302 if (buffer_journal_dirty(bh)) {
3303 count_already_incd = 1; 3303 count_already_incd = 1;
3304 PROC_INFO_INC(p_s_sb, journal.mark_dirty_notjournal); 3304 PROC_INFO_INC(sb, journal.mark_dirty_notjournal);
3305 clear_buffer_journal_dirty(bh); 3305 clear_buffer_journal_dirty(bh);
3306 } 3306 }
3307 3307
@@ -3313,10 +3313,9 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3313 3313
3314 /* now put this guy on the end */ 3314 /* now put this guy on the end */
3315 if (!cn) { 3315 if (!cn) {
3316 cn = get_cnode(p_s_sb); 3316 cn = get_cnode(sb);
3317 if (!cn) { 3317 if (!cn) {
3318 reiserfs_panic(p_s_sb, "journal-4", 3318 reiserfs_panic(sb, "journal-4", "get_cnode failed!");
3319 "get_cnode failed!");
3320 } 3319 }
3321 3320
3322 if (th->t_blocks_logged == th->t_blocks_allocated) { 3321 if (th->t_blocks_logged == th->t_blocks_allocated) {
@@ -3328,7 +3327,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3328 3327
3329 cn->bh = bh; 3328 cn->bh = bh;
3330 cn->blocknr = bh->b_blocknr; 3329 cn->blocknr = bh->b_blocknr;
3331 cn->sb = p_s_sb; 3330 cn->sb = sb;
3332 cn->jlist = NULL; 3331 cn->jlist = NULL;
3333 insert_journal_hash(journal->j_hash_table, cn); 3332 insert_journal_hash(journal->j_hash_table, cn);
3334 if (!count_already_incd) { 3333 if (!count_already_incd) {
@@ -3349,10 +3348,10 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
3349} 3348}
3350 3349
3351int journal_end(struct reiserfs_transaction_handle *th, 3350int journal_end(struct reiserfs_transaction_handle *th,
3352 struct super_block *p_s_sb, unsigned long nblocks) 3351 struct super_block *sb, unsigned long nblocks)
3353{ 3352{
3354 if (!current->journal_info && th->t_refcount > 1) 3353 if (!current->journal_info && th->t_refcount > 1)
3355 reiserfs_warning(p_s_sb, "REISER-NESTING", 3354 reiserfs_warning(sb, "REISER-NESTING",
3356 "th NULL, refcount %d", th->t_refcount); 3355 "th NULL, refcount %d", th->t_refcount);
3357 3356
3358 if (!th->t_trans_id) { 3357 if (!th->t_trans_id) {
@@ -3376,7 +3375,7 @@ int journal_end(struct reiserfs_transaction_handle *th,
3376 } 3375 }
3377 return 0; 3376 return 0;
3378 } else { 3377 } else {
3379 return do_journal_end(th, p_s_sb, nblocks, 0); 3378 return do_journal_end(th, sb, nblocks, 0);
3380 } 3379 }
3381} 3380}
3382 3381
@@ -3387,15 +3386,15 @@ int journal_end(struct reiserfs_transaction_handle *th,
3387** 3386**
3388** returns 1 if it cleaned and relsed the buffer. 0 otherwise 3387** returns 1 if it cleaned and relsed the buffer. 0 otherwise
3389*/ 3388*/
3390static int remove_from_transaction(struct super_block *p_s_sb, 3389static int remove_from_transaction(struct super_block *sb,
3391 b_blocknr_t blocknr, int already_cleaned) 3390 b_blocknr_t blocknr, int already_cleaned)
3392{ 3391{
3393 struct buffer_head *bh; 3392 struct buffer_head *bh;
3394 struct reiserfs_journal_cnode *cn; 3393 struct reiserfs_journal_cnode *cn;
3395 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3394 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3396 int ret = 0; 3395 int ret = 0;
3397 3396
3398 cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr); 3397 cn = get_journal_hash_dev(sb, journal->j_hash_table, blocknr);
3399 if (!cn || !cn->bh) { 3398 if (!cn || !cn->bh) {
3400 return ret; 3399 return ret;
3401 } 3400 }
@@ -3413,7 +3412,7 @@ static int remove_from_transaction(struct super_block *p_s_sb,
3413 journal->j_last = cn->prev; 3412 journal->j_last = cn->prev;
3414 } 3413 }
3415 if (bh) 3414 if (bh)
3416 remove_journal_hash(p_s_sb, journal->j_hash_table, NULL, 3415 remove_journal_hash(sb, journal->j_hash_table, NULL,
3417 bh->b_blocknr, 0); 3416 bh->b_blocknr, 0);
3418 clear_buffer_journaled(bh); /* don't log this one */ 3417 clear_buffer_journaled(bh); /* don't log this one */
3419 3418
@@ -3423,14 +3422,14 @@ static int remove_from_transaction(struct super_block *p_s_sb,
3423 clear_buffer_journal_test(bh); 3422 clear_buffer_journal_test(bh);
3424 put_bh(bh); 3423 put_bh(bh);
3425 if (atomic_read(&(bh->b_count)) < 0) { 3424 if (atomic_read(&(bh->b_count)) < 0) {
3426 reiserfs_warning(p_s_sb, "journal-1752", 3425 reiserfs_warning(sb, "journal-1752",
3427 "b_count < 0"); 3426 "b_count < 0");
3428 } 3427 }
3429 ret = 1; 3428 ret = 1;
3430 } 3429 }
3431 journal->j_len--; 3430 journal->j_len--;
3432 journal->j_len_alloc--; 3431 journal->j_len_alloc--;
3433 free_cnode(p_s_sb, cn); 3432 free_cnode(sb, cn);
3434 return ret; 3433 return ret;
3435} 3434}
3436 3435
@@ -3481,19 +3480,19 @@ static int can_dirty(struct reiserfs_journal_cnode *cn)
3481** will wait until the current transaction is done/committed before returning 3480** will wait until the current transaction is done/committed before returning
3482*/ 3481*/
3483int journal_end_sync(struct reiserfs_transaction_handle *th, 3482int journal_end_sync(struct reiserfs_transaction_handle *th,
3484 struct super_block *p_s_sb, unsigned long nblocks) 3483 struct super_block *sb, unsigned long nblocks)
3485{ 3484{
3486 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3485 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3487 3486
3488 BUG_ON(!th->t_trans_id); 3487 BUG_ON(!th->t_trans_id);
3489 /* you can sync while nested, very, very bad */ 3488 /* you can sync while nested, very, very bad */
3490 BUG_ON(th->t_refcount > 1); 3489 BUG_ON(th->t_refcount > 1);
3491 if (journal->j_len == 0) { 3490 if (journal->j_len == 0) {
3492 reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 3491 reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb),
3493 1); 3492 1);
3494 journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)); 3493 journal_mark_dirty(th, sb, SB_BUFFER_WITH_SB(sb));
3495 } 3494 }
3496 return do_journal_end(th, p_s_sb, nblocks, COMMIT_NOW | WAIT); 3495 return do_journal_end(th, sb, nblocks, COMMIT_NOW | WAIT);
3497} 3496}
3498 3497
3499/* 3498/*
@@ -3503,7 +3502,7 @@ static void flush_async_commits(struct work_struct *work)
3503{ 3502{
3504 struct reiserfs_journal *journal = 3503 struct reiserfs_journal *journal =
3505 container_of(work, struct reiserfs_journal, j_work.work); 3504 container_of(work, struct reiserfs_journal, j_work.work);
3506 struct super_block *p_s_sb = journal->j_work_sb; 3505 struct super_block *sb = journal->j_work_sb;
3507 struct reiserfs_journal_list *jl; 3506 struct reiserfs_journal_list *jl;
3508 struct list_head *entry; 3507 struct list_head *entry;
3509 3508
@@ -3512,7 +3511,7 @@ static void flush_async_commits(struct work_struct *work)
3512 /* last entry is the youngest, commit it and you get everything */ 3511 /* last entry is the youngest, commit it and you get everything */
3513 entry = journal->j_journal_list.prev; 3512 entry = journal->j_journal_list.prev;
3514 jl = JOURNAL_LIST_ENTRY(entry); 3513 jl = JOURNAL_LIST_ENTRY(entry);
3515 flush_commit_list(p_s_sb, jl, 1); 3514 flush_commit_list(sb, jl, 1);
3516 } 3515 }
3517 unlock_kernel(); 3516 unlock_kernel();
3518} 3517}
@@ -3521,11 +3520,11 @@ static void flush_async_commits(struct work_struct *work)
3521** flushes any old transactions to disk 3520** flushes any old transactions to disk
3522** ends the current transaction if it is too old 3521** ends the current transaction if it is too old
3523*/ 3522*/
3524int reiserfs_flush_old_commits(struct super_block *p_s_sb) 3523int reiserfs_flush_old_commits(struct super_block *sb)
3525{ 3524{
3526 time_t now; 3525 time_t now;
3527 struct reiserfs_transaction_handle th; 3526 struct reiserfs_transaction_handle th;
3528 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3527 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3529 3528
3530 now = get_seconds(); 3529 now = get_seconds();
3531 /* safety check so we don't flush while we are replaying the log during 3530 /* safety check so we don't flush while we are replaying the log during
@@ -3542,20 +3541,20 @@ int reiserfs_flush_old_commits(struct super_block *p_s_sb)
3542 journal->j_trans_start_time > 0 && 3541 journal->j_trans_start_time > 0 &&
3543 journal->j_len > 0 && 3542 journal->j_len > 0 &&
3544 (now - journal->j_trans_start_time) > journal->j_max_trans_age) { 3543 (now - journal->j_trans_start_time) > journal->j_max_trans_age) {
3545 if (!journal_join(&th, p_s_sb, 1)) { 3544 if (!journal_join(&th, sb, 1)) {
3546 reiserfs_prepare_for_journal(p_s_sb, 3545 reiserfs_prepare_for_journal(sb,
3547 SB_BUFFER_WITH_SB(p_s_sb), 3546 SB_BUFFER_WITH_SB(sb),
3548 1); 3547 1);
3549 journal_mark_dirty(&th, p_s_sb, 3548 journal_mark_dirty(&th, sb,
3550 SB_BUFFER_WITH_SB(p_s_sb)); 3549 SB_BUFFER_WITH_SB(sb));
3551 3550
3552 /* we're only being called from kreiserfsd, it makes no sense to do 3551 /* we're only being called from kreiserfsd, it makes no sense to do
3553 ** an async commit so that kreiserfsd can do it later 3552 ** an async commit so that kreiserfsd can do it later
3554 */ 3553 */
3555 do_journal_end(&th, p_s_sb, 1, COMMIT_NOW | WAIT); 3554 do_journal_end(&th, sb, 1, COMMIT_NOW | WAIT);
3556 } 3555 }
3557 } 3556 }
3558 return p_s_sb->s_dirt; 3557 return sb->s_dirt;
3559} 3558}
3560 3559
3561/* 3560/*
@@ -3570,7 +3569,7 @@ int reiserfs_flush_old_commits(struct super_block *p_s_sb)
3570** Note, we can't allow the journal_end to proceed while there are still writers in the log. 3569** Note, we can't allow the journal_end to proceed while there are still writers in the log.
3571*/ 3570*/
3572static int check_journal_end(struct reiserfs_transaction_handle *th, 3571static int check_journal_end(struct reiserfs_transaction_handle *th,
3573 struct super_block *p_s_sb, unsigned long nblocks, 3572 struct super_block *sb, unsigned long nblocks,
3574 int flags) 3573 int flags)
3575{ 3574{
3576 3575
@@ -3579,7 +3578,7 @@ static int check_journal_end(struct reiserfs_transaction_handle *th,
3579 int commit_now = flags & COMMIT_NOW; 3578 int commit_now = flags & COMMIT_NOW;
3580 int wait_on_commit = flags & WAIT; 3579 int wait_on_commit = flags & WAIT;
3581 struct reiserfs_journal_list *jl; 3580 struct reiserfs_journal_list *jl;
3582 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3581 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3583 3582
3584 BUG_ON(!th->t_trans_id); 3583 BUG_ON(!th->t_trans_id);
3585 3584
@@ -3618,31 +3617,31 @@ static int check_journal_end(struct reiserfs_transaction_handle *th,
3618 if (flush) { 3617 if (flush) {
3619 journal->j_next_full_flush = 1; 3618 journal->j_next_full_flush = 1;
3620 } 3619 }
3621 unlock_journal(p_s_sb); 3620 unlock_journal(sb);
3622 3621
3623 /* sleep while the current transaction is still j_jlocked */ 3622 /* sleep while the current transaction is still j_jlocked */
3624 while (journal->j_trans_id == trans_id) { 3623 while (journal->j_trans_id == trans_id) {
3625 if (atomic_read(&journal->j_jlock)) { 3624 if (atomic_read(&journal->j_jlock)) {
3626 queue_log_writer(p_s_sb); 3625 queue_log_writer(sb);
3627 } else { 3626 } else {
3628 lock_journal(p_s_sb); 3627 lock_journal(sb);
3629 if (journal->j_trans_id == trans_id) { 3628 if (journal->j_trans_id == trans_id) {
3630 atomic_set(&(journal->j_jlock), 3629 atomic_set(&(journal->j_jlock),
3631 1); 3630 1);
3632 } 3631 }
3633 unlock_journal(p_s_sb); 3632 unlock_journal(sb);
3634 } 3633 }
3635 } 3634 }
3636 BUG_ON(journal->j_trans_id == trans_id); 3635 BUG_ON(journal->j_trans_id == trans_id);
3637 3636
3638 if (commit_now 3637 if (commit_now
3639 && journal_list_still_alive(p_s_sb, trans_id) 3638 && journal_list_still_alive(sb, trans_id)
3640 && wait_on_commit) { 3639 && wait_on_commit) {
3641 flush_commit_list(p_s_sb, jl, 1); 3640 flush_commit_list(sb, jl, 1);
3642 } 3641 }
3643 return 0; 3642 return 0;
3644 } 3643 }
3645 unlock_journal(p_s_sb); 3644 unlock_journal(sb);
3646 return 0; 3645 return 0;
3647 } 3646 }
3648 3647
@@ -3659,12 +3658,12 @@ static int check_journal_end(struct reiserfs_transaction_handle *th,
3659 && journal->j_len_alloc < journal->j_max_batch 3658 && journal->j_len_alloc < journal->j_max_batch
3660 && journal->j_cnode_free > (journal->j_trans_max * 3)) { 3659 && journal->j_cnode_free > (journal->j_trans_max * 3)) {
3661 journal->j_bcount++; 3660 journal->j_bcount++;
3662 unlock_journal(p_s_sb); 3661 unlock_journal(sb);
3663 return 0; 3662 return 0;
3664 } 3663 }
3665 3664
3666 if (journal->j_start > SB_ONDISK_JOURNAL_SIZE(p_s_sb)) { 3665 if (journal->j_start > SB_ONDISK_JOURNAL_SIZE(sb)) {
3667 reiserfs_panic(p_s_sb, "journal-003", 3666 reiserfs_panic(sb, "journal-003",
3668 "j_start (%ld) is too high", 3667 "j_start (%ld) is too high",
3669 journal->j_start); 3668 journal->j_start);
3670 } 3669 }
@@ -3686,16 +3685,16 @@ static int check_journal_end(struct reiserfs_transaction_handle *th,
3686** Then remove it from the current transaction, decrementing any counters and filing it on the clean list. 3685** Then remove it from the current transaction, decrementing any counters and filing it on the clean list.
3687*/ 3686*/
3688int journal_mark_freed(struct reiserfs_transaction_handle *th, 3687int journal_mark_freed(struct reiserfs_transaction_handle *th,
3689 struct super_block *p_s_sb, b_blocknr_t blocknr) 3688 struct super_block *sb, b_blocknr_t blocknr)
3690{ 3689{
3691 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3690 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3692 struct reiserfs_journal_cnode *cn = NULL; 3691 struct reiserfs_journal_cnode *cn = NULL;
3693 struct buffer_head *bh = NULL; 3692 struct buffer_head *bh = NULL;
3694 struct reiserfs_list_bitmap *jb = NULL; 3693 struct reiserfs_list_bitmap *jb = NULL;
3695 int cleaned = 0; 3694 int cleaned = 0;
3696 BUG_ON(!th->t_trans_id); 3695 BUG_ON(!th->t_trans_id);
3697 3696
3698 cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr); 3697 cn = get_journal_hash_dev(sb, journal->j_hash_table, blocknr);
3699 if (cn && cn->bh) { 3698 if (cn && cn->bh) {
3700 bh = cn->bh; 3699 bh = cn->bh;
3701 get_bh(bh); 3700 get_bh(bh);
@@ -3705,15 +3704,15 @@ int journal_mark_freed(struct reiserfs_transaction_handle *th,
3705 clear_buffer_journal_new(bh); 3704 clear_buffer_journal_new(bh);
3706 clear_prepared_bits(bh); 3705 clear_prepared_bits(bh);
3707 reiserfs_clean_and_file_buffer(bh); 3706 reiserfs_clean_and_file_buffer(bh);
3708 cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned); 3707 cleaned = remove_from_transaction(sb, blocknr, cleaned);
3709 } else { 3708 } else {
3710 /* set the bit for this block in the journal bitmap for this transaction */ 3709 /* set the bit for this block in the journal bitmap for this transaction */
3711 jb = journal->j_current_jl->j_list_bitmap; 3710 jb = journal->j_current_jl->j_list_bitmap;
3712 if (!jb) { 3711 if (!jb) {
3713 reiserfs_panic(p_s_sb, "journal-1702", 3712 reiserfs_panic(sb, "journal-1702",
3714 "journal_list_bitmap is NULL"); 3713 "journal_list_bitmap is NULL");
3715 } 3714 }
3716 set_bit_in_list_bitmap(p_s_sb, blocknr, jb); 3715 set_bit_in_list_bitmap(sb, blocknr, jb);
3717 3716
3718 /* Note, the entire while loop is not allowed to schedule. */ 3717 /* Note, the entire while loop is not allowed to schedule. */
3719 3718
@@ -3721,13 +3720,13 @@ int journal_mark_freed(struct reiserfs_transaction_handle *th,
3721 clear_prepared_bits(bh); 3720 clear_prepared_bits(bh);
3722 reiserfs_clean_and_file_buffer(bh); 3721 reiserfs_clean_and_file_buffer(bh);
3723 } 3722 }
3724 cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned); 3723 cleaned = remove_from_transaction(sb, blocknr, cleaned);
3725 3724
3726 /* find all older transactions with this block, make sure they don't try to write it out */ 3725 /* find all older transactions with this block, make sure they don't try to write it out */
3727 cn = get_journal_hash_dev(p_s_sb, journal->j_list_hash_table, 3726 cn = get_journal_hash_dev(sb, journal->j_list_hash_table,
3728 blocknr); 3727 blocknr);
3729 while (cn) { 3728 while (cn) {
3730 if (p_s_sb == cn->sb && blocknr == cn->blocknr) { 3729 if (sb == cn->sb && blocknr == cn->blocknr) {
3731 set_bit(BLOCK_FREED, &cn->state); 3730 set_bit(BLOCK_FREED, &cn->state);
3732 if (cn->bh) { 3731 if (cn->bh) {
3733 if (!cleaned) { 3732 if (!cleaned) {
@@ -3743,7 +3742,7 @@ int journal_mark_freed(struct reiserfs_transaction_handle *th,
3743 put_bh(cn->bh); 3742 put_bh(cn->bh);
3744 if (atomic_read 3743 if (atomic_read
3745 (&(cn->bh->b_count)) < 0) { 3744 (&(cn->bh->b_count)) < 0) {
3746 reiserfs_warning(p_s_sb, 3745 reiserfs_warning(sb,
3747 "journal-2138", 3746 "journal-2138",
3748 "cn->bh->b_count < 0"); 3747 "cn->bh->b_count < 0");
3749 } 3748 }
@@ -3850,18 +3849,18 @@ int reiserfs_commit_for_inode(struct inode *inode)
3850 return __commit_trans_jl(inode, id, jl); 3849 return __commit_trans_jl(inode, id, jl);
3851} 3850}
3852 3851
3853void reiserfs_restore_prepared_buffer(struct super_block *p_s_sb, 3852void reiserfs_restore_prepared_buffer(struct super_block *sb,
3854 struct buffer_head *bh) 3853 struct buffer_head *bh)
3855{ 3854{
3856 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3855 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3857 PROC_INFO_INC(p_s_sb, journal.restore_prepared); 3856 PROC_INFO_INC(sb, journal.restore_prepared);
3858 if (!bh) { 3857 if (!bh) {
3859 return; 3858 return;
3860 } 3859 }
3861 if (test_clear_buffer_journal_restore_dirty(bh) && 3860 if (test_clear_buffer_journal_restore_dirty(bh) &&
3862 buffer_journal_dirty(bh)) { 3861 buffer_journal_dirty(bh)) {
3863 struct reiserfs_journal_cnode *cn; 3862 struct reiserfs_journal_cnode *cn;
3864 cn = get_journal_hash_dev(p_s_sb, 3863 cn = get_journal_hash_dev(sb,
3865 journal->j_list_hash_table, 3864 journal->j_list_hash_table,
3866 bh->b_blocknr); 3865 bh->b_blocknr);
3867 if (cn && can_dirty(cn)) { 3866 if (cn && can_dirty(cn)) {
@@ -3880,10 +3879,10 @@ extern struct tree_balance *cur_tb;
3880** wait on it. 3879** wait on it.
3881** 3880**
3882*/ 3881*/
3883int reiserfs_prepare_for_journal(struct super_block *p_s_sb, 3882int reiserfs_prepare_for_journal(struct super_block *sb,
3884 struct buffer_head *bh, int wait) 3883 struct buffer_head *bh, int wait)
3885{ 3884{
3886 PROC_INFO_INC(p_s_sb, journal.prepare); 3885 PROC_INFO_INC(sb, journal.prepare);
3887 3886
3888 if (!trylock_buffer(bh)) { 3887 if (!trylock_buffer(bh)) {
3889 if (!wait) 3888 if (!wait)
@@ -3931,10 +3930,10 @@ static void flush_old_journal_lists(struct super_block *s)
3931** journal lists, etc just won't happen. 3930** journal lists, etc just won't happen.
3932*/ 3931*/
3933static int do_journal_end(struct reiserfs_transaction_handle *th, 3932static int do_journal_end(struct reiserfs_transaction_handle *th,
3934 struct super_block *p_s_sb, unsigned long nblocks, 3933 struct super_block *sb, unsigned long nblocks,
3935 int flags) 3934 int flags)
3936{ 3935{
3937 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3936 struct reiserfs_journal *journal = SB_JOURNAL(sb);
3938 struct reiserfs_journal_cnode *cn, *next, *jl_cn; 3937 struct reiserfs_journal_cnode *cn, *next, *jl_cn;
3939 struct reiserfs_journal_cnode *last_cn = NULL; 3938 struct reiserfs_journal_cnode *last_cn = NULL;
3940 struct reiserfs_journal_desc *desc; 3939 struct reiserfs_journal_desc *desc;
@@ -3964,14 +3963,14 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
3964 3963
3965 put_fs_excl(); 3964 put_fs_excl();
3966 current->journal_info = th->t_handle_save; 3965 current->journal_info = th->t_handle_save;
3967 reiserfs_check_lock_depth(p_s_sb, "journal end"); 3966 reiserfs_check_lock_depth(sb, "journal end");
3968 if (journal->j_len == 0) { 3967 if (journal->j_len == 0) {
3969 reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 3968 reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb),
3970 1); 3969 1);
3971 journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)); 3970 journal_mark_dirty(th, sb, SB_BUFFER_WITH_SB(sb));
3972 } 3971 }
3973 3972
3974 lock_journal(p_s_sb); 3973 lock_journal(sb);
3975 if (journal->j_next_full_flush) { 3974 if (journal->j_next_full_flush) {
3976 flags |= FLUSH_ALL; 3975 flags |= FLUSH_ALL;
3977 flush = 1; 3976 flush = 1;
@@ -3984,10 +3983,10 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
3984 /* check_journal_end locks the journal, and unlocks if it does not return 1 3983 /* check_journal_end locks the journal, and unlocks if it does not return 1
3985 ** it tells us if we should continue with the journal_end, or just return 3984 ** it tells us if we should continue with the journal_end, or just return
3986 */ 3985 */
3987 if (!check_journal_end(th, p_s_sb, nblocks, flags)) { 3986 if (!check_journal_end(th, sb, nblocks, flags)) {
3988 p_s_sb->s_dirt = 1; 3987 sb->s_dirt = 1;
3989 wake_queued_writers(p_s_sb); 3988 wake_queued_writers(sb);
3990 reiserfs_async_progress_wait(p_s_sb); 3989 reiserfs_async_progress_wait(sb);
3991 goto out; 3990 goto out;
3992 } 3991 }
3993 3992
@@ -4016,8 +4015,8 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4016 4015
4017 /* setup description block */ 4016 /* setup description block */
4018 d_bh = 4017 d_bh =
4019 journal_getblk(p_s_sb, 4018 journal_getblk(sb,
4020 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 4019 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
4021 journal->j_start); 4020 journal->j_start);
4022 set_buffer_uptodate(d_bh); 4021 set_buffer_uptodate(d_bh);
4023 desc = (struct reiserfs_journal_desc *)(d_bh)->b_data; 4022 desc = (struct reiserfs_journal_desc *)(d_bh)->b_data;
@@ -4026,9 +4025,9 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4026 set_desc_trans_id(desc, journal->j_trans_id); 4025 set_desc_trans_id(desc, journal->j_trans_id);
4027 4026
4028 /* setup commit block. Don't write (keep it clean too) this one until after everyone else is written */ 4027 /* setup commit block. Don't write (keep it clean too) this one until after everyone else is written */
4029 c_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 4028 c_bh = journal_getblk(sb, SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
4030 ((journal->j_start + journal->j_len + 4029 ((journal->j_start + journal->j_len +
4031 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))); 4030 1) % SB_ONDISK_JOURNAL_SIZE(sb)));
4032 commit = (struct reiserfs_journal_commit *)c_bh->b_data; 4031 commit = (struct reiserfs_journal_commit *)c_bh->b_data;
4033 memset(c_bh->b_data, 0, c_bh->b_size); 4032 memset(c_bh->b_data, 0, c_bh->b_size);
4034 set_commit_trans_id(commit, journal->j_trans_id); 4033 set_commit_trans_id(commit, journal->j_trans_id);
@@ -4061,12 +4060,12 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4061 ** for each real block, add it to the journal list hash, 4060 ** for each real block, add it to the journal list hash,
4062 ** copy into real block index array in the commit or desc block 4061 ** copy into real block index array in the commit or desc block
4063 */ 4062 */
4064 trans_half = journal_trans_half(p_s_sb->s_blocksize); 4063 trans_half = journal_trans_half(sb->s_blocksize);
4065 for (i = 0, cn = journal->j_first; cn; cn = cn->next, i++) { 4064 for (i = 0, cn = journal->j_first; cn; cn = cn->next, i++) {
4066 if (buffer_journaled(cn->bh)) { 4065 if (buffer_journaled(cn->bh)) {
4067 jl_cn = get_cnode(p_s_sb); 4066 jl_cn = get_cnode(sb);
4068 if (!jl_cn) { 4067 if (!jl_cn) {
4069 reiserfs_panic(p_s_sb, "journal-1676", 4068 reiserfs_panic(sb, "journal-1676",
4070 "get_cnode returned NULL"); 4069 "get_cnode returned NULL");
4071 } 4070 }
4072 if (i == 0) { 4071 if (i == 0) {
@@ -4082,15 +4081,15 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4082 of journal or reserved area */ 4081 of journal or reserved area */
4083 4082
4084 if (is_block_in_log_or_reserved_area 4083 if (is_block_in_log_or_reserved_area
4085 (p_s_sb, cn->bh->b_blocknr)) { 4084 (sb, cn->bh->b_blocknr)) {
4086 reiserfs_panic(p_s_sb, "journal-2332", 4085 reiserfs_panic(sb, "journal-2332",
4087 "Trying to log block %lu, " 4086 "Trying to log block %lu, "
4088 "which is a log block", 4087 "which is a log block",
4089 cn->bh->b_blocknr); 4088 cn->bh->b_blocknr);
4090 } 4089 }
4091 jl_cn->blocknr = cn->bh->b_blocknr; 4090 jl_cn->blocknr = cn->bh->b_blocknr;
4092 jl_cn->state = 0; 4091 jl_cn->state = 0;
4093 jl_cn->sb = p_s_sb; 4092 jl_cn->sb = sb;
4094 jl_cn->bh = cn->bh; 4093 jl_cn->bh = cn->bh;
4095 jl_cn->jlist = jl; 4094 jl_cn->jlist = jl;
4096 insert_journal_hash(journal->j_list_hash_table, jl_cn); 4095 insert_journal_hash(journal->j_list_hash_table, jl_cn);
@@ -4131,11 +4130,11 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4131 char *addr; 4130 char *addr;
4132 struct page *page; 4131 struct page *page;
4133 tmp_bh = 4132 tmp_bh =
4134 journal_getblk(p_s_sb, 4133 journal_getblk(sb,
4135 SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + 4134 SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
4136 ((cur_write_start + 4135 ((cur_write_start +
4137 jindex) % 4136 jindex) %
4138 SB_ONDISK_JOURNAL_SIZE(p_s_sb))); 4137 SB_ONDISK_JOURNAL_SIZE(sb)));
4139 set_buffer_uptodate(tmp_bh); 4138 set_buffer_uptodate(tmp_bh);
4140 page = cn->bh->b_page; 4139 page = cn->bh->b_page;
4141 addr = kmap(page); 4140 addr = kmap(page);
@@ -4149,13 +4148,13 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4149 clear_buffer_journaled(cn->bh); 4148 clear_buffer_journaled(cn->bh);
4150 } else { 4149 } else {
4151 /* JDirty cleared sometime during transaction. don't log this one */ 4150 /* JDirty cleared sometime during transaction. don't log this one */
4152 reiserfs_warning(p_s_sb, "journal-2048", 4151 reiserfs_warning(sb, "journal-2048",
4153 "BAD, buffer in journal hash, " 4152 "BAD, buffer in journal hash, "
4154 "but not JDirty!"); 4153 "but not JDirty!");
4155 brelse(cn->bh); 4154 brelse(cn->bh);
4156 } 4155 }
4157 next = cn->next; 4156 next = cn->next;
4158 free_cnode(p_s_sb, cn); 4157 free_cnode(sb, cn);
4159 cn = next; 4158 cn = next;
4160 cond_resched(); 4159 cond_resched();
4161 } 4160 }
@@ -4165,7 +4164,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4165 ** so we dirty/relse c_bh in flush_commit_list, with commit_left <= 1. 4164 ** so we dirty/relse c_bh in flush_commit_list, with commit_left <= 1.
4166 */ 4165 */
4167 4166
4168 journal->j_current_jl = alloc_journal_list(p_s_sb); 4167 journal->j_current_jl = alloc_journal_list(sb);
4169 4168
4170 /* now it is safe to insert this transaction on the main list */ 4169 /* now it is safe to insert this transaction on the main list */
4171 list_add_tail(&jl->j_list, &journal->j_journal_list); 4170 list_add_tail(&jl->j_list, &journal->j_journal_list);
@@ -4176,7 +4175,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4176 old_start = journal->j_start; 4175 old_start = journal->j_start;
4177 journal->j_start = 4176 journal->j_start =
4178 (journal->j_start + journal->j_len + 4177 (journal->j_start + journal->j_len +
4179 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb); 4178 2) % SB_ONDISK_JOURNAL_SIZE(sb);
4180 atomic_set(&(journal->j_wcount), 0); 4179 atomic_set(&(journal->j_wcount), 0);
4181 journal->j_bcount = 0; 4180 journal->j_bcount = 0;
4182 journal->j_last = NULL; 4181 journal->j_last = NULL;
@@ -4191,7 +4190,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4191 journal->j_len_alloc = 0; 4190 journal->j_len_alloc = 0;
4192 journal->j_next_full_flush = 0; 4191 journal->j_next_full_flush = 0;
4193 journal->j_next_async_flush = 0; 4192 journal->j_next_async_flush = 0;
4194 init_journal_hash(p_s_sb); 4193 init_journal_hash(sb);
4195 4194
4196 // make sure reiserfs_add_jh sees the new current_jl before we 4195 // make sure reiserfs_add_jh sees the new current_jl before we
4197 // write out the tails 4196 // write out the tails
@@ -4220,8 +4219,8 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4220 ** queue don't wait for this proc to flush journal lists and such. 4219 ** queue don't wait for this proc to flush journal lists and such.
4221 */ 4220 */
4222 if (flush) { 4221 if (flush) {
4223 flush_commit_list(p_s_sb, jl, 1); 4222 flush_commit_list(sb, jl, 1);
4224 flush_journal_list(p_s_sb, jl, 1); 4223 flush_journal_list(sb, jl, 1);
4225 } else if (!(jl->j_state & LIST_COMMIT_PENDING)) 4224 } else if (!(jl->j_state & LIST_COMMIT_PENDING))
4226 queue_delayed_work(commit_wq, &journal->j_work, HZ / 10); 4225 queue_delayed_work(commit_wq, &journal->j_work, HZ / 10);
4227 4226
@@ -4235,11 +4234,11 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4235 if (journal->j_start <= temp_jl->j_start) { 4234 if (journal->j_start <= temp_jl->j_start) {
4236 if ((journal->j_start + journal->j_trans_max + 1) >= 4235 if ((journal->j_start + journal->j_trans_max + 1) >=
4237 temp_jl->j_start) { 4236 temp_jl->j_start) {
4238 flush_used_journal_lists(p_s_sb, temp_jl); 4237 flush_used_journal_lists(sb, temp_jl);
4239 goto first_jl; 4238 goto first_jl;
4240 } else if ((journal->j_start + 4239 } else if ((journal->j_start +
4241 journal->j_trans_max + 1) < 4240 journal->j_trans_max + 1) <
4242 SB_ONDISK_JOURNAL_SIZE(p_s_sb)) { 4241 SB_ONDISK_JOURNAL_SIZE(sb)) {
4243 /* if we don't cross into the next transaction and we don't 4242 /* if we don't cross into the next transaction and we don't
4244 * wrap, there is no way we can overlap any later transactions 4243 * wrap, there is no way we can overlap any later transactions
4245 * break now 4244 * break now
@@ -4248,11 +4247,11 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4248 } 4247 }
4249 } else if ((journal->j_start + 4248 } else if ((journal->j_start +
4250 journal->j_trans_max + 1) > 4249 journal->j_trans_max + 1) >
4251 SB_ONDISK_JOURNAL_SIZE(p_s_sb)) { 4250 SB_ONDISK_JOURNAL_SIZE(sb)) {
4252 if (((journal->j_start + journal->j_trans_max + 1) % 4251 if (((journal->j_start + journal->j_trans_max + 1) %
4253 SB_ONDISK_JOURNAL_SIZE(p_s_sb)) >= 4252 SB_ONDISK_JOURNAL_SIZE(sb)) >=
4254 temp_jl->j_start) { 4253 temp_jl->j_start) {
4255 flush_used_journal_lists(p_s_sb, temp_jl); 4254 flush_used_journal_lists(sb, temp_jl);
4256 goto first_jl; 4255 goto first_jl;
4257 } else { 4256 } else {
4258 /* we don't overlap anything from out start to the end of the 4257 /* we don't overlap anything from out start to the end of the
@@ -4263,34 +4262,34 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4263 } 4262 }
4264 } 4263 }
4265 } 4264 }
4266 flush_old_journal_lists(p_s_sb); 4265 flush_old_journal_lists(sb);
4267 4266
4268 journal->j_current_jl->j_list_bitmap = 4267 journal->j_current_jl->j_list_bitmap =
4269 get_list_bitmap(p_s_sb, journal->j_current_jl); 4268 get_list_bitmap(sb, journal->j_current_jl);
4270 4269
4271 if (!(journal->j_current_jl->j_list_bitmap)) { 4270 if (!(journal->j_current_jl->j_list_bitmap)) {
4272 reiserfs_panic(p_s_sb, "journal-1996", 4271 reiserfs_panic(sb, "journal-1996",
4273 "could not get a list bitmap"); 4272 "could not get a list bitmap");
4274 } 4273 }
4275 4274
4276 atomic_set(&(journal->j_jlock), 0); 4275 atomic_set(&(journal->j_jlock), 0);
4277 unlock_journal(p_s_sb); 4276 unlock_journal(sb);
4278 /* wake up any body waiting to join. */ 4277 /* wake up any body waiting to join. */
4279 clear_bit(J_WRITERS_QUEUED, &journal->j_state); 4278 clear_bit(J_WRITERS_QUEUED, &journal->j_state);
4280 wake_up(&(journal->j_join_wait)); 4279 wake_up(&(journal->j_join_wait));
4281 4280
4282 if (!flush && wait_on_commit && 4281 if (!flush && wait_on_commit &&
4283 journal_list_still_alive(p_s_sb, commit_trans_id)) { 4282 journal_list_still_alive(sb, commit_trans_id)) {
4284 flush_commit_list(p_s_sb, jl, 1); 4283 flush_commit_list(sb, jl, 1);
4285 } 4284 }
4286 out: 4285 out:
4287 reiserfs_check_lock_depth(p_s_sb, "journal end2"); 4286 reiserfs_check_lock_depth(sb, "journal end2");
4288 4287
4289 memset(th, 0, sizeof(*th)); 4288 memset(th, 0, sizeof(*th));
4290 /* Re-set th->t_super, so we can properly keep track of how many 4289 /* Re-set th->t_super, so we can properly keep track of how many
4291 * persistent transactions there are. We need to do this so if this 4290 * persistent transactions there are. We need to do this so if this
4292 * call is part of a failed restart_transaction, we can free it later */ 4291 * call is part of a failed restart_transaction, we can free it later */
4293 th->t_super = p_s_sb; 4292 th->t_super = sb;
4294 4293
4295 return journal->j_errno; 4294 return journal->j_errno;
4296} 4295}