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:
  JFS: Remove incorrect kgdb define
  JFS: call io_schedule() instead of schedule() to avoid deadlock
  JFS: Add lockdep annotations
  JFS: Avoid BUG() on a damaged file system
  • Loading branch information
Linus Torvalds committed Feb 7, 2007
2 parents d3f8fd7 + 7220c01 commit 5331be0
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 49 deletions.
6 changes: 3 additions & 3 deletions fs/jfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
* Take appropriate lock on inode
*/
if (create)
IWRITE_LOCK(ip);
IWRITE_LOCK(ip, RDWRLOCK_NORMAL);
else
IREAD_LOCK(ip);
IREAD_LOCK(ip, RDWRLOCK_NORMAL);

if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) &&
(!xtLookup(ip, lblock64, xlen, &xflag, &xaddr, &xlen, 0)) &&
Expand Down Expand Up @@ -359,7 +359,7 @@ void jfs_truncate(struct inode *ip)

nobh_truncate_page(ip->i_mapping, ip->i_size);

IWRITE_LOCK(ip);
IWRITE_LOCK(ip, RDWRLOCK_NORMAL);
jfs_truncate_nolock(ip, ip->i_size);
IWRITE_UNLOCK(ip);
}
5 changes: 0 additions & 5 deletions fs/jfs/jfs_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,13 @@ extern void jfs_proc_clean(void);
/*
* assert with traditional printf/panic
*/
#ifdef CONFIG_KERNEL_ASSERTS
/* kgdb stuff */
#define assert(p) KERNEL_ASSERT(#p, p)
#else
#define assert(p) do { \
if (!(p)) { \
printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \
__FILE__, __LINE__, #p); \
BUG(); \
} \
} while (0)
#endif

/*
* debug ON
Expand Down
16 changes: 8 additions & 8 deletions fs/jfs/jfs_dmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ int dbFree(struct inode *ip, s64 blkno, s64 nblocks)
struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap;
struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;

IREAD_LOCK(ipbmap);
IREAD_LOCK(ipbmap, RDWRLOCK_DMAP);

/* block to be freed better be within the mapsize. */
if (unlikely((blkno == 0) || (blkno + nblocks > bmp->db_mapsize))) {
Expand Down Expand Up @@ -733,7 +733,7 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
* allocation group size, try to allocate anywhere.
*/
if (l2nb > bmp->db_agl2size) {
IWRITE_LOCK(ipbmap);
IWRITE_LOCK(ipbmap, RDWRLOCK_DMAP);

rc = dbAllocAny(bmp, nblocks, l2nb, results);

Expand Down Expand Up @@ -774,7 +774,7 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
* the hint using a tiered strategy.
*/
if (nblocks <= BPERDMAP) {
IREAD_LOCK(ipbmap);
IREAD_LOCK(ipbmap, RDWRLOCK_DMAP);

/* get the buffer for the dmap containing the hint.
*/
Expand Down Expand Up @@ -844,7 +844,7 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
/* try to satisfy the allocation request with blocks within
* the same allocation group as the hint.
*/
IWRITE_LOCK(ipbmap);
IWRITE_LOCK(ipbmap, RDWRLOCK_DMAP);
if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) != -ENOSPC)
goto write_unlock;

Expand All @@ -856,7 +856,7 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
* Let dbNextAG recommend a preferred allocation group
*/
agno = dbNextAG(ipbmap);
IWRITE_LOCK(ipbmap);
IWRITE_LOCK(ipbmap, RDWRLOCK_DMAP);

/* Try to allocate within this allocation group. if that fails, try to
* allocate anywhere in the map.
Expand Down Expand Up @@ -900,7 +900,7 @@ int dbAllocExact(struct inode *ip, s64 blkno, int nblocks)
s64 lblkno;
struct metapage *mp;

IREAD_LOCK(ipbmap);
IREAD_LOCK(ipbmap, RDWRLOCK_DMAP);

/*
* validate extent request:
Expand Down Expand Up @@ -1050,7 +1050,7 @@ static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks)
*/
extblkno = lastblkno + 1;

IREAD_LOCK(ipbmap);
IREAD_LOCK(ipbmap, RDWRLOCK_DMAP);

/* better be within the file system */
bmp = sbi->bmap;
Expand Down Expand Up @@ -3116,7 +3116,7 @@ int dbAllocBottomUp(struct inode *ip, s64 blkno, s64 nblocks)
struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap;
struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;

IREAD_LOCK(ipbmap);
IREAD_LOCK(ipbmap, RDWRLOCK_DMAP);

/* block to be allocated better be within the mapsize. */
ASSERT(nblocks <= bmp->db_mapsize - blkno);
Expand Down
16 changes: 8 additions & 8 deletions fs/jfs/jfs_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ int diRead(struct inode *ip)

/* read the iag */
imap = JFS_IP(ipimap)->i_imap;
IREAD_LOCK(ipimap);
IREAD_LOCK(ipimap, RDWRLOCK_IMAP);
rc = diIAGRead(imap, iagno, &mp);
IREAD_UNLOCK(ipimap);
if (rc) {
Expand Down Expand Up @@ -920,7 +920,7 @@ int diFree(struct inode *ip)
/* Obtain read lock in imap inode. Don't release it until we have
* read all of the IAG's that we are going to.
*/
IREAD_LOCK(ipimap);
IREAD_LOCK(ipimap, RDWRLOCK_IMAP);

/* read the iag.
*/
Expand Down Expand Up @@ -1415,7 +1415,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
AG_LOCK(imap, agno);

/* Get read lock on imap inode */
IREAD_LOCK(ipimap);
IREAD_LOCK(ipimap, RDWRLOCK_IMAP);

/* get the iag number and read the iag */
iagno = INOTOIAG(inum);
Expand Down Expand Up @@ -1808,7 +1808,7 @@ static int diAllocIno(struct inomap * imap, int agno, struct inode *ip)
return -ENOSPC;

/* obtain read lock on imap inode */
IREAD_LOCK(imap->im_ipimap);
IREAD_LOCK(imap->im_ipimap, RDWRLOCK_IMAP);

/* read the iag at the head of the list.
*/
Expand Down Expand Up @@ -1946,7 +1946,7 @@ static int diAllocExt(struct inomap * imap, int agno, struct inode *ip)
} else {
/* read the iag.
*/
IREAD_LOCK(imap->im_ipimap);
IREAD_LOCK(imap->im_ipimap, RDWRLOCK_IMAP);
if ((rc = diIAGRead(imap, iagno, &mp))) {
IREAD_UNLOCK(imap->im_ipimap);
jfs_error(ip->i_sb, "diAllocExt: error reading iag");
Expand Down Expand Up @@ -2509,7 +2509,7 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
*/

/* acquire inode map lock */
IWRITE_LOCK(ipimap);
IWRITE_LOCK(ipimap, RDWRLOCK_IMAP);

if (ipimap->i_size >> L2PSIZE != imap->im_nextiag + 1) {
IWRITE_UNLOCK(ipimap);
Expand Down Expand Up @@ -2648,7 +2648,7 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
}

/* obtain read lock on map */
IREAD_LOCK(ipimap);
IREAD_LOCK(ipimap, RDWRLOCK_IMAP);

/* read the iag */
if ((rc = diIAGRead(imap, iagno, &mp))) {
Expand Down Expand Up @@ -2779,7 +2779,7 @@ diUpdatePMap(struct inode *ipimap,
return -EIO;
}
/* read the iag */
IREAD_LOCK(ipimap);
IREAD_LOCK(ipimap, RDWRLOCK_IMAP);
rc = diIAGRead(imap, iagno, &mp);
IREAD_UNLOCK(ipimap);
if (rc)
Expand Down
29 changes: 27 additions & 2 deletions fs/jfs/jfs_incore.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ struct jfs_inode_info {

#define JFS_ACL_NOT_CACHED ((void *)-1)

#define IREAD_LOCK(ip) down_read(&JFS_IP(ip)->rdwrlock)
#define IREAD_LOCK(ip, subclass) \
down_read_nested(&JFS_IP(ip)->rdwrlock, subclass)
#define IREAD_UNLOCK(ip) up_read(&JFS_IP(ip)->rdwrlock)
#define IWRITE_LOCK(ip) down_write(&JFS_IP(ip)->rdwrlock)
#define IWRITE_LOCK(ip, subclass) \
down_write_nested(&JFS_IP(ip)->rdwrlock, subclass)
#define IWRITE_UNLOCK(ip) up_write(&JFS_IP(ip)->rdwrlock)

/*
Expand All @@ -127,6 +129,29 @@ enum cflags {
COMMIT_Synclist, /* metadata pages on group commit synclist */
};

/*
* commit_mutex nesting subclasses:
*/
enum commit_mutex_class
{
COMMIT_MUTEX_PARENT,
COMMIT_MUTEX_CHILD,
COMMIT_MUTEX_SECOND_PARENT, /* Renaming */
COMMIT_MUTEX_VICTIM /* Inode being unlinked due to rename */
};

/*
* rdwrlock subclasses:
* The dmap inode may be locked while a normal inode or the imap inode are
* locked.
*/
enum rdwrlock_class
{
RDWRLOCK_NORMAL,
RDWRLOCK_IMAP,
RDWRLOCK_DMAP
};

#define set_cflag(flag, ip) set_bit(flag, &(JFS_IP(ip)->cflag))
#define clear_cflag(flag, ip) clear_bit(flag, &(JFS_IP(ip)->cflag))
#define test_cflag(flag, ip) test_bit(flag, &(JFS_IP(ip)->cflag))
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/jfs_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ do { \
if (cond) \
break; \
unlock_cmd; \
schedule(); \
io_schedule(); \
lock_cmd; \
} \
current->state = TASK_RUNNING; \
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/jfs_metapage.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static inline void __lock_metapage(struct metapage *mp)
set_current_state(TASK_UNINTERRUPTIBLE);
if (metapage_locked(mp)) {
unlock_page(mp->page);
schedule();
io_schedule();
lock_page(mp->page);
}
} while (trylock_metapage(mp));
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/jfs_txnmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static inline void TXN_SLEEP_DROP_LOCK(wait_queue_head_t * event)
add_wait_queue(event, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
TXN_UNLOCK();
schedule();
io_schedule();
current->state = TASK_RUNNING;
remove_wait_queue(event, &wait);
}
Expand Down
15 changes: 15 additions & 0 deletions fs/jfs/jfs_xtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,11 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
nsplit = 0;

/* push (bn, index) of the parent page/entry */
if (BT_STACK_FULL(btstack)) {
jfs_error(ip->i_sb, "stack overrun in xtSearch!");
XT_PUTPAGE(mp);
return -EIO;
}
BT_PUSH(btstack, bn, index);

/* get the child page block number */
Expand Down Expand Up @@ -3915,6 +3920,11 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
*/
getChild:
/* save current parent entry for the child page */
if (BT_STACK_FULL(&btstack)) {
jfs_error(ip->i_sb, "stack overrun in xtTruncate!");
XT_PUTPAGE(mp);
return -EIO;
}
BT_PUSH(&btstack, bn, index);

/* get child page */
Expand Down Expand Up @@ -4112,6 +4122,11 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
*/
getChild:
/* save current parent entry for the child page */
if (BT_STACK_FULL(&btstack)) {
jfs_error(ip->i_sb, "stack overrun in xtTruncate_pmap!");
XT_PUTPAGE(mp);
return -EIO;
}
BT_PUSH(&btstack, bn, index);

/* get child page */
Expand Down
Loading

0 comments on commit 5331be0

Please sign in to comment.