From a66e12d6ede2afda3bb7a5b1f22b8c17c1176584 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 20 Feb 2014 14:00:08 -0800 Subject: [PATCH] LU-216 ldiskfs: use proper arguments for ldiskfs_free_blocks In ldiskfs_ext_new_extent_cb(), the extent length argument is confusingly converted from le16 using cpu_to_le16() instead of le16_to_cpu(). While this is functionally correct, it is semantically incorrect and can confuse static code analysis. Signed-off-by: Andrew Perepechko Signed-off-by: Andreas Dilger Change-Id: I8b3a684677c66d96fe4828fa771fc309c21755b8 Reviewed-on: http://review.whamcloud.com/1720 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: John L. Hammond --- config/lustre-build-ldiskfs.m4 | 1 + lustre/osd-ldiskfs/osd_io.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/lustre-build-ldiskfs.m4 b/config/lustre-build-ldiskfs.m4 index bdcae9a..e34e75a 100644 --- a/config/lustre-build-ldiskfs.m4 +++ b/config/lustre-build-ldiskfs.m4 @@ -35,6 +35,7 @@ AC_SUBST(LDISKFS_SERIES) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD # # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head +# Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed. # AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [ LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'], diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index d223585..0a73cb0 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -664,11 +664,12 @@ static int ldiskfs_ext_new_extent_cb(struct inode *inode, * but otherwise we'd need to call it every free() */ ldiskfs_discard_preallocations(inode); #ifdef HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD /* Introduced in 2.6.32-rc7 */ - ldiskfs_free_blocks(handle, inode, NULL, ldiskfs_ext_pblock(&nex), - cpu_to_le16(nex.ee_len), 0); + ldiskfs_free_blocks(handle, inode, NULL, + ldiskfs_ext_pblock(&nex), + le16_to_cpu(nex.ee_len), 0); #else ldiskfs_free_blocks(handle, inode, ldiskfs_ext_pblock(&nex), - cpu_to_le16(nex.ee_len), 0); + le16_to_cpu(nex.ee_len), 0); #endif goto out; } -- 1.8.3.1