From patchwork Tue Dec 11 06:39:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ma X-Patchwork-Id: 205128 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 EF3A22C0090 for ; Tue, 11 Dec 2012 17:40:06 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859Ab2LKGkD (ORCPT ); Tue, 11 Dec 2012 01:40:03 -0500 Received: from oproxy11-pub.bluehost.com ([173.254.64.10]:37311 "HELO oproxy11-pub.bluehost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752853Ab2LKGkC (ORCPT ); Tue, 11 Dec 2012 01:40:02 -0500 Received: (qmail 5277 invoked by uid 0); 11 Dec 2012 06:40:01 -0000 Received: from unknown (HELO box585.bluehost.com) (66.147.242.185) by oproxy11.bluehost.com with SMTP; 11 Dec 2012 06:40:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tao.ma; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=/M8CvBCHkjPAKEdhJ4v9h4Ft6zC0x3K10e/P5Ly3Voo=; b=WQL99j3fsWC+1n/jrpZMMXnSB68UFAudkXD70yXMTJDmWOxMMjZ6Xlb2EmdNyYcNUuWE0ea2mcioFXrWui3da1wb4ygIa8xHSRhxMjF3NR1mWsPUOb4SRMeQEYn/Uipj; Received: from [182.92.247.2] (port=53475 helo=tma-laptop1.taobao.ali.com) by box585.bluehost.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76) (envelope-from ) id 1TiJVY-0000sy-MM; Mon, 10 Dec 2012 23:40:01 -0700 From: Tao Ma To: linux-ext4@vger.kernel.org Cc: "Theodore Ts'o" Subject: [PATCH] ext4: Add EXT4_ZERO_XATTR_VALUE to init inline data directly. Date: Tue, 11 Dec 2012 14:39:49 +0800 Message-Id: <1355207989-4823-1-git-send-email-tm@tao.ma> X-Mailer: git-send-email 1.7.9.5 X-Identified-User: {1390:box585.bluehost.com:colyli:tao.ma} {sentby:smtp auth 182.92.247.2 authed with tm@tao.ma} Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Tao Ma Build rebot found this error: config: make ARCH=sparc allyesconfig All error/warnings: fs/ext4/inline.c: In function 'ext4_create_inline_data': fs/ext4/inline.c:268:19: error: 'empty_zero_page' undeclared (first use in this function) fs/ext4/inline.c:268:19: note: each undeclared identifier is reported only once for each function it appears in fs/ext4/inline.c: At top level: fs/ext4/inline.c:164:12: warning: 'ext4_read_inline_data' defined but not used [-Wunused-function] In sparc, it seems that we don't have empty_zero_page, so add a new specific value EXT4_ZERO_XATTR_VALUE so that when ext4_xattr_set_entry see this flag memset the space directly instead of copying from value. This idea is inspired by Theodore Ts'o. Cc: "Theodore Ts'o" Signed-off-by: Tao Ma --- fs/ext4/inline.c | 2 +- fs/ext4/xattr.c | 22 ++++++++++++++++------ fs/ext4/xattr.h | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 6b600b4..e435343 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -263,7 +263,7 @@ static int ext4_create_inline_data(handle_t *handle, goto out; if (len > EXT4_MIN_INLINE_DATA_SIZE) { - value = (void *)empty_zero_page; + value = EXT4_ZERO_XATTR_VALUE; len -= EXT4_MIN_INLINE_DATA_SIZE; } else { value = ""; diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 2251769..3a91ebc 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -628,9 +628,14 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s) size. Just replace. */ s->here->e_value_size = cpu_to_le32(i->value_len); - memset(val + size - EXT4_XATTR_PAD, 0, - EXT4_XATTR_PAD); /* Clear pad bytes. */ - memcpy(val, i->value, i->value_len); + if (i->value == EXT4_ZERO_XATTR_VALUE) { + memset(val, 0, size); + } else { + /* Clear pad bytes first. */ + memset(val + size - EXT4_XATTR_PAD, 0, + EXT4_XATTR_PAD); + memcpy(val, i->value, i->value_len); + } return 0; } @@ -669,9 +674,14 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s) size_t size = EXT4_XATTR_SIZE(i->value_len); void *val = s->base + min_offs - size; s->here->e_value_offs = cpu_to_le16(min_offs - size); - memset(val + size - EXT4_XATTR_PAD, 0, - EXT4_XATTR_PAD); /* Clear the pad bytes. */ - memcpy(val, i->value, i->value_len); + if (i->value == EXT4_ZERO_XATTR_VALUE) { + memset(val, 0, size); + } else { + /* Clear the pad bytes first. */ + memset(val + size - EXT4_XATTR_PAD, 0, + EXT4_XATTR_PAD); + memcpy(val, i->value, i->value_len); + } } } return 0; diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h index c33fa41..17a6e44 100644 --- a/fs/ext4/xattr.h +++ b/fs/ext4/xattr.h @@ -71,6 +71,7 @@ struct ext4_xattr_entry { #define BFIRST(bh) ENTRY(BHDR(bh)+1) #define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0) +#define EXT4_ZERO_XATTR_VALUE ((void *)-1) struct ext4_xattr_info { int name_index;