Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
Linus Torvalds committed Jan 25, 2008
2 parents b47711b + 5c5e32c commit 2d94dfc
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 62 deletions.
27 changes: 12 additions & 15 deletions fs/jfs/jfs_dtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ static struct dir_table_slot *find_index(struct inode *ip, u32 index,
release_metapage(*mp);
*mp = NULL;
}
if (*mp == 0) {
if (!(*mp)) {
*lblock = blkno;
*mp = read_index_page(ip, blkno);
}
if (*mp == 0) {
if (!(*mp)) {
jfs_err("free_index: error reading directory table");
return NULL;
}
Expand Down Expand Up @@ -413,7 +413,8 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
}
ip->i_size = PSIZE;

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

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

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

if (dirtab_slot == 0)
if (!dirtab_slot)
return;

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

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

if (dirtab_slot == 0)
if (!dirtab_slot)
return;

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

slot = find_index(ip, index, &mp, &lblock);
if (slot == 0) {
if (!slot) {
return -EIO;
}

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

ciKey.name =
(wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
GFP_NOFS);
if (ciKey.name == 0) {
ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS);
if (!ciKey.name) {
rc = -ENOMEM;
goto dtSearch_Exit2;
}
Expand Down Expand Up @@ -957,10 +956,8 @@ static int dtSplitUp(tid_t tid,
smp = split->mp;
sp = DT_PAGE(ip, smp);

key.name =
(wchar_t *) kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t),
GFP_NOFS);
if (key.name == 0) {
key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS);
if (!key.name) {
DT_PUTPAGE(smp);
rc = -ENOMEM;
goto dtSplitUp_Exit;
Expand Down
4 changes: 2 additions & 2 deletions fs/jfs/jfs_dtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct idtentry {
#define DTIHDRDATALEN 11

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


/*
Expand Down Expand Up @@ -133,7 +133,7 @@ struct dir_table_slot {
( ((s64)((dts)->addr1)) << 32 | __le32_to_cpu((dts)->addr2) )

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


Expand Down
4 changes: 2 additions & 2 deletions fs/jfs/jfs_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ int diRead(struct inode *ip)

/* read the page of disk inode */
mp = read_metapage(ipimap, pageno << sbi->l2nbperpage, PSIZE, 1);
if (mp == 0) {
if (!mp) {
jfs_err("diRead: read_metapage failed");
return -EIO;
}
Expand Down Expand Up @@ -654,7 +654,7 @@ int diWrite(tid_t tid, struct inode *ip)
/* read the page of disk inode */
retry:
mp = read_metapage(ipimap, pageno << sbi->l2nbperpage, PSIZE, 1);
if (mp == 0)
if (!mp)
return -EIO;

/* get the pointer to the disk inode */
Expand Down
34 changes: 16 additions & 18 deletions fs/jfs/jfs_logmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ static struct lmStat {
} lmStat;
#endif

static void write_special_inodes(struct jfs_log *log,
int (*writer)(struct address_space *))
{
struct jfs_sb_info *sbi;

list_for_each_entry(sbi, &log->sb_list, log_list) {
writer(sbi->ipbmap->i_mapping);
writer(sbi->ipimap->i_mapping);
writer(sbi->direct_inode->i_mapping);
}
}

/*
* NAME: lmLog()
Expand Down Expand Up @@ -935,22 +946,13 @@ static int lmLogSync(struct jfs_log * log, int hard_sync)
struct lrd lrd;
int lsn;
struct logsyncblk *lp;
struct jfs_sb_info *sbi;
unsigned long flags;

/* push dirty metapages out to disk */
if (hard_sync)
list_for_each_entry(sbi, &log->sb_list, log_list) {
filemap_fdatawrite(sbi->ipbmap->i_mapping);
filemap_fdatawrite(sbi->ipimap->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
}
write_special_inodes(log, filemap_fdatawrite);
else
list_for_each_entry(sbi, &log->sb_list, log_list) {
filemap_flush(sbi->ipbmap->i_mapping);
filemap_flush(sbi->ipimap->i_mapping);
filemap_flush(sbi->direct_inode->i_mapping);
}
write_special_inodes(log, filemap_flush);

/*
* forward syncpt
Expand Down Expand Up @@ -1536,7 +1538,6 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
{
int i;
struct tblock *target = NULL;
struct jfs_sb_info *sbi;

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

list_for_each_entry(sbi, &log->sb_list, log_list) {
filemap_fdatawrite(sbi->ipbmap->i_mapping);
filemap_fdatawrite(sbi->ipimap->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
}
write_special_inodes(log, filemap_fdatawrite);

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

do {
spin_lock_irq(&log_redrive_lock);
while ((bp = log_redrive_list) != 0) {
while ((bp = log_redrive_list)) {
log_redrive_list = bp->l_redrive_next;
bp->l_redrive_next = NULL;
spin_unlock_irq(&log_redrive_lock);
Expand Down
43 changes: 24 additions & 19 deletions fs/jfs/jfs_metapage.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ static struct {
#endif

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

static inline void unlock_metapage(struct metapage *mp)
{
clear_bit(META_locked, &mp->flag);
clear_bit_unlock(META_locked, &mp->flag);
wake_up(&mp->wait);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ struct meta_anchor {
};
#define mp_anchor(page) ((struct meta_anchor *)page_private(page))

static inline struct metapage *page_to_mp(struct page *page, uint offset)
static inline struct metapage *page_to_mp(struct page *page, int offset)
{
if (!PagePrivate(page))
return NULL;
Expand Down Expand Up @@ -153,7 +153,7 @@ static inline void dec_io(struct page *page, void (*handler) (struct page *))
}

#else
static inline struct metapage *page_to_mp(struct page *page, uint offset)
static inline struct metapage *page_to_mp(struct page *page, int offset)
{
return PagePrivate(page) ? (struct metapage *)page_private(page) : NULL;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ static inline void drop_metapage(struct page *page, struct metapage *mp)
*/

static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
unsigned int *len)
int *len)
{
int rc = 0;
int xflag;
Expand Down Expand Up @@ -352,25 +352,27 @@ static void metapage_write_end_io(struct bio *bio, int err)
static int metapage_writepage(struct page *page, struct writeback_control *wbc)
{
struct bio *bio = NULL;
unsigned int block_offset; /* block offset of mp within page */
int block_offset; /* block offset of mp within page */
struct inode *inode = page->mapping->host;
unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
unsigned int len;
unsigned int xlen;
int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
int len;
int xlen;
struct metapage *mp;
int redirty = 0;
sector_t lblock;
int nr_underway = 0;
sector_t pblock;
sector_t next_block = 0;
sector_t page_start;
unsigned long bio_bytes = 0;
unsigned long bio_offset = 0;
unsigned int offset;
int offset;

page_start = (sector_t)page->index <<
(PAGE_CACHE_SHIFT - inode->i_blkbits);
BUG_ON(!PageLocked(page));
BUG_ON(PageWriteback(page));
set_page_writeback(page);

for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
mp = page_to_mp(page, offset);
Expand Down Expand Up @@ -413,11 +415,10 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
if (!bio->bi_size)
goto dump_bio;
submit_bio(WRITE, bio);
nr_underway++;
bio = NULL;
} else {
set_page_writeback(page);
} else
inc_io(page);
}
xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits;
pblock = metapage_get_blocks(inode, lblock, &xlen);
if (!pblock) {
Expand All @@ -427,7 +428,7 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
continue;
}
set_bit(META_io, &mp->flag);
len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage);
len = min(xlen, (int)JFS_SBI(inode->i_sb)->nbperpage);

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

submit_bio(WRITE, bio);
nr_underway++;
}
if (redirty)
redirty_page_for_writepage(wbc, page);

unlock_page(page);

if (nr_underway == 0)
end_page_writeback(page);

return 0;
add_failed:
/* We should never reach here, since we're only adding one vec */
Expand All @@ -475,13 +480,13 @@ static int metapage_readpage(struct file *fp, struct page *page)
{
struct inode *inode = page->mapping->host;
struct bio *bio = NULL;
unsigned int block_offset;
unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
int block_offset;
int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
sector_t page_start; /* address of page in fs blocks */
sector_t pblock;
unsigned int xlen;
int xlen;
unsigned int len;
unsigned int offset;
int offset;

BUG_ON(!PageLocked(page));
page_start = (sector_t)page->index <<
Expand Down Expand Up @@ -530,7 +535,7 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
{
struct metapage *mp;
int ret = 1;
unsigned int offset;
int offset;

for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
mp = page_to_mp(page, offset);
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/jfs_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int jfs_mount(struct super_block *sb)
*/
if ((sbi->mntflag & JFS_BAD_SAIT) == 0) {
ipaimap2 = diReadSpecial(sb, AGGREGATE_I, 1);
if (ipaimap2 == 0) {
if (!ipaimap2) {
jfs_err("jfs_mount: Faild to read AGGREGATE_I");
rc = -EIO;
goto errout35;
Expand Down
4 changes: 2 additions & 2 deletions fs/jfs/jfs_umount.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int jfs_umount(struct super_block *sb)
/*
* Wait for outstanding transactions to be written to log:
*/
jfs_flush_journal(log, 2);
jfs_flush_journal(log, 1);

/*
* close fileset inode allocation map (aka fileset inode)
Expand Down Expand Up @@ -146,7 +146,7 @@ int jfs_umount_rw(struct super_block *sb)
*
* remove file system from log active file system list.
*/
jfs_flush_journal(log, 2);
jfs_flush_journal(log, 1);

/*
* Make sure all metadata makes it to disk
Expand Down
4 changes: 2 additions & 2 deletions fs/jfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
* Make sure dest inode number (if any) is what we think it is
*/
rc = dtSearch(new_dir, &new_dname, &ino, &btstack, JFS_LOOKUP);
if (rc == 0) {
if ((new_ip == 0) || (ino != new_ip->i_ino)) {
if (!rc) {
if ((!new_ip) || (ino != new_ip->i_ino)) {
rc = -ESTALE;
goto out3;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
*/
t64 = ((newLVSize - newLogSize + BPERDMAP - 1) >> L2BPERDMAP)
<< L2BPERDMAP;
t32 = ((t64 + (BITSPERPAGE - 1)) / BITSPERPAGE) + 1 + 50;
t32 = DIV_ROUND_UP(t64, BITSPERPAGE) + 1 + 50;
newFSCKSize = t32 << sbi->l2nbperpage;
newFSCKAddress = newLogAddress - newFSCKSize;

Expand Down
Loading

0 comments on commit 2d94dfc

Please sign in to comment.