From 55b02d74e126df70fb6b92a0e4e4bed2f0a13fe4 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Fri, 25 Nov 2005 16:41:33 +1100 Subject: [XFS] Fix potential overflow in xfs_iomap_t delta for very large extents SGI-PV: 945311 SGI-Modid: xfs-linux-melb:xfs-kern:201708a Signed-off-by: Eric Sandeen Signed-off-by: Nathan Scott --- fs/xfs/xfs_iomap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index fcd6d63bb68..3ce204a524b 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h @@ -69,7 +69,7 @@ typedef struct xfs_iomap { xfs_buftarg_t *iomap_target; xfs_off_t iomap_offset; /* offset of mapping, bytes */ xfs_off_t iomap_bsize; /* size of mapping, bytes */ - size_t iomap_delta; /* offset into mapping, bytes */ + xfs_off_t iomap_delta; /* offset into mapping, bytes */ iomap_flags_t iomap_flags; } xfs_iomap_t; -- cgit v1.2.3 From f33c6797bccc695c4c85885f2c676ad4c8fed98d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 25 Nov 2005 16:41:47 +1100 Subject: [XFS] handle error returns from freeze_bdev SGI-PV: 945483 SGI-Modid: xfs-linux-melb:xfs-kern:201884a Signed-off-by: Christoph Hellwig Signed-off-by: Nathan Scott --- fs/xfs/xfs_fsops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 7ceabd0e2d9..d1236d6f404 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -550,7 +550,7 @@ xfs_fs_goingdown( struct vfs *vfsp = XFS_MTOVFS(mp); struct super_block *sb = freeze_bdev(vfsp->vfs_super->s_bdev); - if (sb) { + if (sb && !IS_ERR(sb)) { xfs_force_shutdown(mp, XFS_FORCE_UMOUNT); thaw_bdev(sb->s_bdev, sb); } -- cgit v1.2.3 From a4656391b76ed93faed724c5963f033164ee477e Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Fri, 25 Nov 2005 16:41:57 +1100 Subject: [XFS] Fix a 32 bit value wraparound when providing a mapping for a large direct write. SGI-PV: 944820 SGI-Modid: xfs-linux-melb:xfs-kern:24351a Signed-off-by: Nathan Scott --- fs/xfs/linux-2.6/xfs_aops.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'fs') diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index c6108971b4e..94d3cdfbf9b 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c @@ -941,13 +941,12 @@ __linvfs_get_block( int retpbbm = 1; int error; - if (blocks) { - offset = blocks << inode->i_blkbits; /* 64 bit goodness */ - size = (ssize_t) min_t(xfs_off_t, offset, LONG_MAX); - } else { - size = 1 << inode->i_blkbits; - } offset = (xfs_off_t)iblock << inode->i_blkbits; + if (blocks) + size = (ssize_t) min_t(xfs_off_t, LONG_MAX, + (xfs_off_t)blocks << inode->i_blkbits); + else + size = 1 << inode->i_blkbits; VOP_BMAP(vp, offset, size, create ? flags : BMAPI_READ, &iomap, &retpbbm, error); @@ -1007,7 +1006,7 @@ __linvfs_get_block( ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0); offset = min_t(xfs_off_t, iomap.iomap_bsize - iomap.iomap_delta, - blocks << inode->i_blkbits); + (xfs_off_t)blocks << inode->i_blkbits); bh_result->b_size = (u32) min_t(xfs_off_t, UINT_MAX, offset); } -- cgit v1.2.3 From 6b2cf618cc8445a03640d1e5e36829352e297017 Mon Sep 17 00:00:00 2001 From: Felix Blyakher Date: Fri, 25 Nov 2005 16:42:13 +1100 Subject: [XFS] Tight loop in xfs_finish_reclaim_all prevented the xfslogd to run its queue of IO completion callbacks, thus creating the deadlock between umount and xfslogd. Breaking the loop solves the problem. SGI-PV: 943821 SGI-Modid: xfs-linux-melb:xfs-kern:202363a Signed-off-by: Felix Blyakher Signed-off-by: Nathan Scott --- fs/xfs/xfs_vnodeops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'fs') diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 7c1f7453146..e03fa2a3d5e 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c @@ -3958,8 +3958,9 @@ xfs_finish_reclaim_all(xfs_mount_t *mp, int noblock) } } XFS_MOUNT_IUNLOCK(mp); - xfs_finish_reclaim(ip, noblock, - XFS_IFLUSH_DELWRI_ELSE_ASYNC); + if (xfs_finish_reclaim(ip, noblock, + XFS_IFLUSH_DELWRI_ELSE_ASYNC)) + delay(1); purged = 1; break; } -- cgit v1.2.3 From e0144ca55391556d781cb1c90fd6f00bb0c20760 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Fri, 25 Nov 2005 16:42:22 +1100 Subject: [XFS] Fix a case where attr2 format was being used unconditionally. SGI-PV: 941645 SGI-Modid: xfs-linux-melb:xfs-kern:24566a Signed-off-by: Nathan Scott --- fs/xfs/xfs_attr_leaf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 35e557b00db..1c7421840c1 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c @@ -310,7 +310,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) * Fix up the start offset of the attribute fork */ totsize -= size; - if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname) { + if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname && + !(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) { /* * Last attribute now removed, revert to original * inode format making all literal area available @@ -328,7 +329,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); ASSERT(dp->i_d.di_forkoff); - ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname); + ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname || + (mp->m_flags & XFS_MOUNT_COMPAT_ATTR)); dp->i_afp->if_ext_max = XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); dp->i_df.if_ext_max = @@ -737,7 +739,8 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) + name_loc->namelen + INT_GET(name_loc->valuelen, ARCH_CONVERT); } - if (bytes == sizeof(struct xfs_attr_sf_hdr)) + if (!(dp->i_mount->m_flags & XFS_MOUNT_COMPAT_ATTR) && + (bytes == sizeof(struct xfs_attr_sf_hdr))) return(-1); return(xfs_attr_shortform_bytesfit(dp, bytes)); } @@ -775,6 +778,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) goto out; if (forkoff == -1) { + ASSERT(!(dp->i_mount->m_flags & XFS_MOUNT_COMPAT_ATTR)); + /* * Last attribute was removed, revert to original * inode format making all literal area available -- cgit v1.2.3 From 551c81e2d32c5867fb592091365d8c37e1509dce Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Fri, 25 Nov 2005 16:42:28 +1100 Subject: [XFS] Resolve the xlog_grant_log_space hang, revert inline to macro. SGI-PV: 946205 SGI-Modid: xfs-linux-melb:xfs-kern:24567a Signed-off-by: Nathan Scott --- fs/xfs/xfs_log_priv.h | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'fs') diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 8f285149681..4518b188ade 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -494,10 +494,8 @@ typedef struct log { #define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR) -#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \ - xlog_grant_sub_space(log,bytes,type) -static inline void xlog_grant_sub_space(struct log *log, int bytes, int type) -{ +#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \ + { \ if (type == 'w') { \ (log)->l_grant_write_bytes -= (bytes); \ if ((log)->l_grant_write_bytes < 0) { \ @@ -511,13 +509,9 @@ static inline void xlog_grant_sub_space(struct log *log, int bytes, int type) (log)->l_grant_reserve_cycle--; \ } \ } \ -} - -#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \ - xlog_grant_add_space(log,bytes,type) -static inline void -xlog_grant_add_space(struct log *log, int bytes, int type) -{ + } +#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \ + { \ if (type == 'w') { \ (log)->l_grant_write_bytes += (bytes); \ if ((log)->l_grant_write_bytes > (log)->l_logsize) { \ @@ -531,12 +525,9 @@ xlog_grant_add_space(struct log *log, int bytes, int type) (log)->l_grant_reserve_cycle++; \ } \ } \ -} - -#define XLOG_INS_TICKETQ(q, tic) xlog_ins_ticketq(q, tic) -static inline void -xlog_ins_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic) -{ \ + } +#define XLOG_INS_TICKETQ(q, tic) \ + { \ if (q) { \ (tic)->t_next = (q); \ (tic)->t_prev = (q)->t_prev; \ @@ -547,12 +538,9 @@ xlog_ins_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic) (q) = (tic); \ } \ (tic)->t_flags |= XLOG_TIC_IN_Q; \ -} - -#define XLOG_DEL_TICKETQ(q, tic) xlog_del_ticketq(q, tic) -static inline void -xlog_del_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic) -{ \ + } +#define XLOG_DEL_TICKETQ(q, tic) \ + { \ if ((tic) == (tic)->t_next) { \ (q) = NULL; \ } else { \ @@ -562,7 +550,7 @@ xlog_del_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic) } \ (tic)->t_next = (tic)->t_prev = NULL; \ (tic)->t_flags &= ~XLOG_TIC_IN_Q; \ -} + } /* common routines */ extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); -- cgit v1.2.3