From patchwork Sat Apr 12 09:16:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 338670 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9EB1B140100 for ; Sat, 12 Apr 2014 19:10:25 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754027AbaDLJKY (ORCPT ); Sat, 12 Apr 2014 05:10:24 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:59486 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752134AbaDLJKV (ORCPT ); Sat, 12 Apr 2014 05:10:21 -0400 Received: by mail-pd0-f178.google.com with SMTP id x10so6201845pdj.23 for ; Sat, 12 Apr 2014 02:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PSViUd9Jfs+DgCoQiMqWmXPy5gCZyWizbnBSV8KU9Xs=; b=iGlADrBHsQUpHJOCXrwM3r5wqfaGI2n7xGi3vcyKP0EyAuSf7uyQej5uE7JV34dUb8 N8r2vmJ2NXOh95bdiSsCd6IvLQK74uU/hGahH9ZbxfIPmIMMpIM1jTxMurmxRwaDEk1C PaeGNjiA3UKKlC9Dx/yo8s1VAIrDQ9iDlMULbc/XFAU6ZVz65Qrr1JEvehjKDM57r537 P4RDreuJw9sJ7g0a9DZLpJAUmoOV5ylapaUgzwFO64DP3rZgs7gwH68WPsWVFe2fLi4Y LpMondWMns8LJv+dwkZJIJZzvdWL4gM+80Hqnn7afWE5ThnItqG73IedcYVo8bwQG+lL etyw== X-Received: by 10.68.240.5 with SMTP id vw5mr32497791pbc.113.1397293821109; Sat, 12 Apr 2014 02:10:21 -0700 (PDT) Received: from alpha.taobao.ali.com ([182.92.253.17]) by mx.google.com with ESMTPSA id ir10sm20662093pbc.59.2014.04.12.02.10.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 12 Apr 2014 02:10:20 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: "Theodore Ts'o" , Andreas Dilger , Namjae Jeon , Zheng Liu Subject: [PATCH] ext4: fix some warnings from sparse check introduced by COLLAPSE_RANGE patches Date: Sat, 12 Apr 2014 17:16:18 +0800 Message-Id: <1397294178-20383-1-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.9.7 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu This commit tries to fix some byte order issues that is found by sparse check. $ make M=fs/ext4 C=2 CF=-D__CHECK_ENDIAN__ ... CHECK fs/ext4/extents.c fs/ext4/extents.c:5232:41: warning: restricted __le32 degrades to integer fs/ext4/extents.c:5236:52: warning: bad assignment (-=) to restricted __le32 fs/ext4/extents.c:5258:45: warning: bad assignment (-=) to restricted __le32 fs/ext4/extents.c:5303:28: warning: restricted __le32 degrades to integer fs/ext4/extents.c:5318:18: warning: incorrect type in assignment (different base types) fs/ext4/extents.c:5318:18: expected unsigned int [unsigned] [usertype] ex_start fs/ext4/extents.c:5318:18: got restricted __le32 [usertype] ee_block fs/ext4/extents.c:5319:24: warning: restricted __le32 degrades to integer fs/ext4/extents.c:5334:31: warning: incorrect type in assignment (different base types) ... Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Namjae Jeon Signed-off-by: Zheng Liu --- fs/ext4/extents.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 82df3ce..1867af6 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5229,11 +5229,11 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) update = 1; - *start = ex_last->ee_block + + *start = le32_to_cpu(ex_last->ee_block) + ext4_ext_get_actual_len(ex_last); while (ex_start <= ex_last) { - ex_start->ee_block -= shift; + le32_add_cpu(&ex_start->ee_block, -shift); if (ex_start > EXT_FIRST_EXTENT(path[depth].p_hdr)) { if (ext4_ext_try_to_merge_right(inode, @@ -5255,7 +5255,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, if (err) goto out; - path[depth].p_idx->ei_block -= shift; + le32_add_cpu(&path[depth].p_idx->ei_block, -shift); err = ext4_ext_dirty(handle, inode, path + depth); if (err) goto out; @@ -5300,7 +5300,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, return ret; } - stop_block = extent->ee_block + ext4_ext_get_actual_len(extent); + stop_block = le32_to_cpu(extent->ee_block) + + ext4_ext_get_actual_len(extent); ext4_ext_drop_refs(path); kfree(path); @@ -5315,8 +5316,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, path = ext4_ext_find_extent(inode, start - 1, NULL, 0); depth = path->p_depth; extent = path[depth].p_ext; - ex_start = extent->ee_block; - ex_end = extent->ee_block + ext4_ext_get_actual_len(extent); + ex_start = le32_to_cpu(extent->ee_block); + ex_end = le32_to_cpu(extent->ee_block) + + ext4_ext_get_actual_len(extent); ext4_ext_drop_refs(path); kfree(path); @@ -5331,7 +5333,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, return PTR_ERR(path); depth = path->p_depth; extent = path[depth].p_ext; - current_block = extent->ee_block; + current_block = le32_to_cpu(extent->ee_block); if (start > current_block) { /* Hole, move to the next extent */ ret = mext_next_extent(inode, path, &extent);