Skip to content

Commit 2d94dfc

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy/jfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy/jfs-2.6: mount options: fix jfs JFS: simplify types to get rid of sparse warning JFS: FIx one more plain integer as NULL pointer warning JFS: Remove defconfig ptr comparison to 0 JFS: use DIV_ROUND_UP where appropriate Remove unnecessary kmalloc casts in the jfs filesystem JFS is missing a memory barrier JFS: Make sure special inode data is written after journal is flushed JFS: clear PAGECACHE_TAG_DIRTY for no-write pages
2 parents b47711b + 5c5e32c commit 2d94dfc

File tree

10 files changed

+68
-62
lines changed

10 files changed

+68
-62
lines changed

fs/jfs/jfs_dtree.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ static struct dir_table_slot *find_index(struct inode *ip, u32 index,
284284
release_metapage(*mp);
285285
*mp = NULL;
286286
}
287-
if (*mp == 0) {
287+
if (!(*mp)) {
288288
*lblock = blkno;
289289
*mp = read_index_page(ip, blkno);
290290
}
291-
if (*mp == 0) {
291+
if (!(*mp)) {
292292
jfs_err("free_index: error reading directory table");
293293
return NULL;
294294
}
@@ -413,7 +413,8 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
413413
}
414414
ip->i_size = PSIZE;
415415

416-
if ((mp = get_index_page(ip, 0)) == 0) {
416+
mp = get_index_page(ip, 0);
417+
if (!mp) {
417418
jfs_err("add_index: get_metapage failed!");
418419
xtTruncate(tid, ip, 0, COMMIT_PWMAP);
419420
memcpy(&jfs_ip->i_dirtable, temp_table,
@@ -461,7 +462,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
461462
} else
462463
mp = read_index_page(ip, blkno);
463464

464-
if (mp == 0) {
465+
if (!mp) {
465466
jfs_err("add_index: get/read_metapage failed!");
466467
goto clean_up;
467468
}
@@ -499,7 +500,7 @@ static void free_index(tid_t tid, struct inode *ip, u32 index, u32 next)
499500

500501
dirtab_slot = find_index(ip, index, &mp, &lblock);
501502

502-
if (dirtab_slot == 0)
503+
if (!dirtab_slot)
503504
return;
504505

505506
dirtab_slot->flag = DIR_INDEX_FREE;
@@ -526,7 +527,7 @@ static void modify_index(tid_t tid, struct inode *ip, u32 index, s64 bn,
526527

527528
dirtab_slot = find_index(ip, index, mp, lblock);
528529

529-
if (dirtab_slot == 0)
530+
if (!dirtab_slot)
530531
return;
531532

532533
DTSaddress(dirtab_slot, bn);
@@ -552,7 +553,7 @@ static int read_index(struct inode *ip, u32 index,
552553
struct dir_table_slot *slot;
553554

554555
slot = find_index(ip, index, &mp, &lblock);
555-
if (slot == 0) {
556+
if (!slot) {
556557
return -EIO;
557558
}
558559

@@ -592,10 +593,8 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data,
592593
struct component_name ciKey;
593594
struct super_block *sb = ip->i_sb;
594595

595-
ciKey.name =
596-
(wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
597-
GFP_NOFS);
598-
if (ciKey.name == 0) {
596+
ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS);
597+
if (!ciKey.name) {
599598
rc = -ENOMEM;
600599
goto dtSearch_Exit2;
601600
}
@@ -957,10 +956,8 @@ static int dtSplitUp(tid_t tid,
957956
smp = split->mp;
958957
sp = DT_PAGE(ip, smp);
959958

960-
key.name =
961-
(wchar_t *) kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t),
962-
GFP_NOFS);
963-
if (key.name == 0) {
959+
key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS);
960+
if (!key.name) {
964961
DT_PUTPAGE(smp);
965962
rc = -ENOMEM;
966963
goto dtSplitUp_Exit;

fs/jfs/jfs_dtree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct idtentry {
7474
#define DTIHDRDATALEN 11
7575

7676
/* compute number of slots for entry */
77-
#define NDTINTERNAL(klen) ( ((4 + (klen)) + (15 - 1)) / 15 )
77+
#define NDTINTERNAL(klen) (DIV_ROUND_UP((4 + (klen)), 15))
7878

7979

8080
/*
@@ -133,7 +133,7 @@ struct dir_table_slot {
133133
( ((s64)((dts)->addr1)) << 32 | __le32_to_cpu((dts)->addr2) )
134134

135135
/* compute number of slots for entry */
136-
#define NDTLEAF_LEGACY(klen) ( ((2 + (klen)) + (15 - 1)) / 15 )
136+
#define NDTLEAF_LEGACY(klen) (DIV_ROUND_UP((2 + (klen)), 15))
137137
#define NDTLEAF NDTINTERNAL
138138

139139

fs/jfs/jfs_imap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ int diRead(struct inode *ip)
381381

382382
/* read the page of disk inode */
383383
mp = read_metapage(ipimap, pageno << sbi->l2nbperpage, PSIZE, 1);
384-
if (mp == 0) {
384+
if (!mp) {
385385
jfs_err("diRead: read_metapage failed");
386386
return -EIO;
387387
}
@@ -654,7 +654,7 @@ int diWrite(tid_t tid, struct inode *ip)
654654
/* read the page of disk inode */
655655
retry:
656656
mp = read_metapage(ipimap, pageno << sbi->l2nbperpage, PSIZE, 1);
657-
if (mp == 0)
657+
if (!mp)
658658
return -EIO;
659659

660660
/* get the pointer to the disk inode */

fs/jfs/jfs_logmgr.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ static struct lmStat {
208208
} lmStat;
209209
#endif
210210

211+
static void write_special_inodes(struct jfs_log *log,
212+
int (*writer)(struct address_space *))
213+
{
214+
struct jfs_sb_info *sbi;
215+
216+
list_for_each_entry(sbi, &log->sb_list, log_list) {
217+
writer(sbi->ipbmap->i_mapping);
218+
writer(sbi->ipimap->i_mapping);
219+
writer(sbi->direct_inode->i_mapping);
220+
}
221+
}
211222

212223
/*
213224
* NAME: lmLog()
@@ -935,22 +946,13 @@ static int lmLogSync(struct jfs_log * log, int hard_sync)
935946
struct lrd lrd;
936947
int lsn;
937948
struct logsyncblk *lp;
938-
struct jfs_sb_info *sbi;
939949
unsigned long flags;
940950

941951
/* push dirty metapages out to disk */
942952
if (hard_sync)
943-
list_for_each_entry(sbi, &log->sb_list, log_list) {
944-
filemap_fdatawrite(sbi->ipbmap->i_mapping);
945-
filemap_fdatawrite(sbi->ipimap->i_mapping);
946-
filemap_fdatawrite(sbi->direct_inode->i_mapping);
947-
}
953+
write_special_inodes(log, filemap_fdatawrite);
948954
else
949-
list_for_each_entry(sbi, &log->sb_list, log_list) {
950-
filemap_flush(sbi->ipbmap->i_mapping);
951-
filemap_flush(sbi->ipimap->i_mapping);
952-
filemap_flush(sbi->direct_inode->i_mapping);
953-
}
955+
write_special_inodes(log, filemap_flush);
954956

955957
/*
956958
* forward syncpt
@@ -1536,7 +1538,6 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
15361538
{
15371539
int i;
15381540
struct tblock *target = NULL;
1539-
struct jfs_sb_info *sbi;
15401541

15411542
/* jfs_write_inode may call us during read-only mount */
15421543
if (!log)
@@ -1598,11 +1599,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
15981599
if (wait < 2)
15991600
return;
16001601

1601-
list_for_each_entry(sbi, &log->sb_list, log_list) {
1602-
filemap_fdatawrite(sbi->ipbmap->i_mapping);
1603-
filemap_fdatawrite(sbi->ipimap->i_mapping);
1604-
filemap_fdatawrite(sbi->direct_inode->i_mapping);
1605-
}
1602+
write_special_inodes(log, filemap_fdatawrite);
16061603

16071604
/*
16081605
* If there was recent activity, we may need to wait
@@ -1611,6 +1608,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
16111608
if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) {
16121609
for (i = 0; i < 200; i++) { /* Too much? */
16131610
msleep(250);
1611+
write_special_inodes(log, filemap_fdatawrite);
16141612
if (list_empty(&log->cqueue) &&
16151613
list_empty(&log->synclist))
16161614
break;
@@ -2347,7 +2345,7 @@ int jfsIOWait(void *arg)
23472345

23482346
do {
23492347
spin_lock_irq(&log_redrive_lock);
2350-
while ((bp = log_redrive_list) != 0) {
2348+
while ((bp = log_redrive_list)) {
23512349
log_redrive_list = bp->l_redrive_next;
23522350
bp->l_redrive_next = NULL;
23532351
spin_unlock_irq(&log_redrive_lock);

fs/jfs/jfs_metapage.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ static struct {
3939
#endif
4040

4141
#define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)
42-
#define trylock_metapage(mp) test_and_set_bit(META_locked, &(mp)->flag)
42+
#define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag)
4343

4444
static inline void unlock_metapage(struct metapage *mp)
4545
{
46-
clear_bit(META_locked, &mp->flag);
46+
clear_bit_unlock(META_locked, &mp->flag);
4747
wake_up(&mp->wait);
4848
}
4949

@@ -88,7 +88,7 @@ struct meta_anchor {
8888
};
8989
#define mp_anchor(page) ((struct meta_anchor *)page_private(page))
9090

91-
static inline struct metapage *page_to_mp(struct page *page, uint offset)
91+
static inline struct metapage *page_to_mp(struct page *page, int offset)
9292
{
9393
if (!PagePrivate(page))
9494
return NULL;
@@ -153,7 +153,7 @@ static inline void dec_io(struct page *page, void (*handler) (struct page *))
153153
}
154154

155155
#else
156-
static inline struct metapage *page_to_mp(struct page *page, uint offset)
156+
static inline struct metapage *page_to_mp(struct page *page, int offset)
157157
{
158158
return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL;
159159
}
@@ -249,7 +249,7 @@ static inline void drop_metapage(struct page *page, struct metapage *mp)
249249
*/
250250

251251
static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
252-
unsigned int *len)
252+
int *len)
253253
{
254254
int rc = 0;
255255
int xflag;
@@ -352,25 +352,27 @@ static void metapage_write_end_io(struct bio *bio, int err)
352352
static int metapage_writepage(struct page *page, struct writeback_control *wbc)
353353
{
354354
struct bio *bio = NULL;
355-
unsigned int block_offset; /* block offset of mp within page */
355+
int block_offset; /* block offset of mp within page */
356356
struct inode *inode = page->mapping->host;
357-
unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
358-
unsigned int len;
359-
unsigned int xlen;
357+
int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
358+
int len;
359+
int xlen;
360360
struct metapage *mp;
361361
int redirty = 0;
362362
sector_t lblock;
363+
int nr_underway = 0;
363364
sector_t pblock;
364365
sector_t next_block = 0;
365366
sector_t page_start;
366367
unsigned long bio_bytes = 0;
367368
unsigned long bio_offset = 0;
368-
unsigned int offset;
369+
int offset;
369370

370371
page_start = (sector_t)page->index <<
371372
(PAGE_CACHE_SHIFT - inode->i_blkbits);
372373
BUG_ON(!PageLocked(page));
373374
BUG_ON(PageWriteback(page));
375+
set_page_writeback(page);
374376

375377
for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
376378
mp = page_to_mp(page, offset);
@@ -413,11 +415,10 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
413415
if (!bio->bi_size)
414416
goto dump_bio;
415417
submit_bio(WRITE, bio);
418+
nr_underway++;
416419
bio = NULL;
417-
} else {
418-
set_page_writeback(page);
420+
} else
419421
inc_io(page);
420-
}
421422
xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits;
422423
pblock = metapage_get_blocks(inode, lblock, &xlen);
423424
if (!pblock) {
@@ -427,7 +428,7 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
427428
continue;
428429
}
429430
set_bit(META_io, &mp->flag);
430-
len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage);
431+
len = min(xlen, (int)JFS_SBI(inode->i_sb)->nbperpage);
431432

432433
bio = bio_alloc(GFP_NOFS, 1);
433434
bio->bi_bdev = inode->i_sb->s_bdev;
@@ -449,12 +450,16 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
449450
goto dump_bio;
450451

451452
submit_bio(WRITE, bio);
453+
nr_underway++;
452454
}
453455
if (redirty)
454456
redirty_page_for_writepage(wbc, page);
455457

456458
unlock_page(page);
457459

460+
if (nr_underway == 0)
461+
end_page_writeback(page);
462+
458463
return 0;
459464
add_failed:
460465
/* We should never reach here, since we're only adding one vec */
@@ -475,13 +480,13 @@ static int metapage_readpage(struct file *fp, struct page *page)
475480
{
476481
struct inode *inode = page->mapping->host;
477482
struct bio *bio = NULL;
478-
unsigned int block_offset;
479-
unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
483+
int block_offset;
484+
int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
480485
sector_t page_start; /* address of page in fs blocks */
481486
sector_t pblock;
482-
unsigned int xlen;
487+
int xlen;
483488
unsigned int len;
484-
unsigned int offset;
489+
int offset;
485490

486491
BUG_ON(!PageLocked(page));
487492
page_start = (sector_t)page->index <<
@@ -530,7 +535,7 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
530535
{
531536
struct metapage *mp;
532537
int ret = 1;
533-
unsigned int offset;
538+
int offset;
534539

535540
for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
536541
mp = page_to_mp(page, offset);

fs/jfs/jfs_mount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int jfs_mount(struct super_block *sb)
147147
*/
148148
if ((sbi->mntflag & JFS_BAD_SAIT) == 0) {
149149
ipaimap2 = diReadSpecial(sb, AGGREGATE_I, 1);
150-
if (ipaimap2 == 0) {
150+
if (!ipaimap2) {
151151
jfs_err("jfs_mount: Faild to read AGGREGATE_I");
152152
rc = -EIO;
153153
goto errout35;

fs/jfs/jfs_umount.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int jfs_umount(struct super_block *sb)
6868
/*
6969
* Wait for outstanding transactions to be written to log:
7070
*/
71-
jfs_flush_journal(log, 2);
71+
jfs_flush_journal(log, 1);
7272

7373
/*
7474
* close fileset inode allocation map (aka fileset inode)
@@ -146,7 +146,7 @@ int jfs_umount_rw(struct super_block *sb)
146146
*
147147
* remove file system from log active file system list.
148148
*/
149-
jfs_flush_journal(log, 2);
149+
jfs_flush_journal(log, 1);
150150

151151
/*
152152
* Make sure all metadata makes it to disk

fs/jfs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
11031103
* Make sure dest inode number (if any) is what we think it is
11041104
*/
11051105
rc = dtSearch(new_dir, &new_dname, &ino, &btstack, JFS_LOOKUP);
1106-
if (rc == 0) {
1107-
if ((new_ip == 0) || (ino != new_ip->i_ino)) {
1106+
if (!rc) {
1107+
if ((!new_ip) || (ino != new_ip->i_ino)) {
11081108
rc = -ESTALE;
11091109
goto out3;
11101110
}

fs/jfs/resize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
172172
*/
173173
t64 = ((newLVSize - newLogSize + BPERDMAP - 1) >> L2BPERDMAP)
174174
<< L2BPERDMAP;
175-
t32 = ((t64 + (BITSPERPAGE - 1)) / BITSPERPAGE) + 1 + 50;
175+
t32 = DIV_ROUND_UP(t64, BITSPERPAGE) + 1 + 50;
176176
newFSCKSize = t32 << sbi->l2nbperpage;
177177
newFSCKAddress = newLogAddress - newFSCKSize;
178178

0 commit comments

Comments
 (0)