diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-04-30 21:39:35 +1000 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-05-01 14:13:55 -0500 |
commit | 946217ba28637d7a08e03e93ef40586ce621f557 (patch) | |
tree | 5939657206b29c7678a347a3a13ea4880a1d4f82 /fs/xfs | |
parent | 123887e8433e58ebbcc4c91491d8b8cde31d6d79 (diff) | |
download | op-kernel-dev-946217ba28637d7a08e03e93ef40586ce621f557.zip op-kernel-dev-946217ba28637d7a08e03e93ef40586ce621f557.tar.gz |
xfs: Remote attr validation fixes and optimisations
- optimise the calcuation for the number of blocks in a remote
xattr.
- check attribute length against MAX_XATTR_SIZE, not MAXPATHLEN
- whitespace fixes
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_attr_remote.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/xfs/xfs_attr_remote.c b/fs/xfs/xfs_attr_remote.c index 53da46b..dee8446 100644 --- a/fs/xfs/xfs_attr_remote.c +++ b/fs/xfs/xfs_attr_remote.c @@ -52,15 +52,9 @@ xfs_attr3_rmt_blocks( struct xfs_mount *mp, int attrlen) { - int fsblocks = 0; - int len = attrlen; - - do { - fsblocks++; - len -= XFS_ATTR3_RMT_BUF_SPACE(mp, mp->m_sb.sb_blocksize); - } while (len > 0); - - return fsblocks; + int buflen = XFS_ATTR3_RMT_BUF_SPACE(mp, + mp->m_sb.sb_blocksize); + return (attrlen + buflen - 1) / buflen; } static bool @@ -79,7 +73,7 @@ xfs_attr3_rmt_verify( if (bp->b_bn != be64_to_cpu(rmt->rm_blkno)) return false; if (be32_to_cpu(rmt->rm_offset) + - be32_to_cpu(rmt->rm_bytes) >= MAXPATHLEN) + be32_to_cpu(rmt->rm_bytes) >= XATTR_SIZE_MAX) return false; if (rmt->rm_owner == 0) return false; @@ -183,7 +177,6 @@ xfs_attr3_rmt_hdr_ok( /* ok */ return true; - } /* @@ -367,7 +360,6 @@ xfs_attr_rmtval_set( * spill for another block every 9 headers we require in this * loop. */ - if (crcs && blkcnt == 0) { int total_len; @@ -422,9 +414,8 @@ xfs_attr_rmtval_set( byte_cnt = BBTOB(bp->b_length); byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, byte_cnt); - if (valuelen < byte_cnt) { + if (valuelen < byte_cnt) byte_cnt = valuelen; - } buf = bp->b_addr; buf += xfs_attr3_rmt_hdr_set(mp, dp->i_ino, offset, |