From patchwork Wed May 31 08:14:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 9756253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCCD560360 for ; Wed, 31 May 2017 08:28:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBE011FF8F for ; Wed, 31 May 2017 08:28:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFDBF283BD; Wed, 31 May 2017 08:28:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 431621FF8F for ; Wed, 31 May 2017 08:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbdEaIRG (ORCPT ); Wed, 31 May 2017 04:17:06 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:36329 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321AbdEaIRC (ORCPT ); Wed, 31 May 2017 04:17:02 -0400 Received: by mail-pg0-f46.google.com with SMTP id x64so4571772pgd.3 for ; Wed, 31 May 2017 01:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uIFA3i6eSFU3wAH6g+40GW2OKF0S1dlCJRK5JBvUCRU=; b=JR1wA2eJ7arauA/X+A6RQBix9zGqyGTUOXSlJlvpG1obJIefkOowGPHC0cg6+LTpbe H9lOhedtFvzQ+5T0Czw8neHpOH1UN27fmTnL60EP9PjAtqxa3Ve69VoKFIe7eGpVZhKH VNxgDLZtlJhBl7F10KjD6eCDEtMa0TzTSMk2Xot9BBL76z27nCG5OVFAZgp2V4auhBAZ tBPLchnsG6cnDkJbvZjSlMOLYk+9pYv0jlOkis6LgfoPQ8K1h3kT0BA5WvmaqgNElEH6 VbEbsU2LXSziiopBP6InAiQ8KjEeSeBecfbHb0B27McRDMjn9i/htoZDdVcTa4cGyWd5 CWJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uIFA3i6eSFU3wAH6g+40GW2OKF0S1dlCJRK5JBvUCRU=; b=QlaZAWk+oNyhJ2Uwfd5GOt+GJPQE60csEOcbBmDeLwegwEqerHCJh1Gmbt5q8LrIxL 42+LfvCoJ/t+/wdzAfpe0enn78+o9KSZSx2nQAPbDebDtrHZM7x5YWdz04RVsGSHVdWY fCF8GHSzhksX00bIb0ldCkscSFXDjIryAkxwHcyqZS9US/mArQKyj4+F6IsNoeNcPdHi bcdF+pjCLyc+erGEFLB2F4Q1Se6EMJXgerk7qDvLIVjPCAGBBxNdNeA6JNhZPlU1NbOQ FHNBjOMp1mvE46zTkuLU6sGKihHgSmbE8mbfQM4S4wAKzpmdlN4+xgRdAqMzt3OIkiWV T2mA== X-Gm-Message-State: AODbwcBcXw/+0l91R5tqqPo8qLfGfwi6v9YGbDonRJIr6vq1VBU5mhxe F3K94IeWTzRvUz7h X-Received: by 10.99.113.20 with SMTP id m20mr29936350pgc.120.1496218616942; Wed, 31 May 2017 01:16:56 -0700 (PDT) Received: from tahsin1.svl.corp.google.com ([100.123.230.167]) by smtp.gmail.com with ESMTPSA id g75sm25469724pfd.83.2017.05.31.01.16.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 01:16:56 -0700 (PDT) From: Tahsin Erdogan To: Jan Kara , Theodore Ts'o , Andreas Dilger , Dave Kleikamp , Alexander Viro , Mark Fasheh , Joel Becker , Jens Axboe , Deepa Dinamani , Mike Christie , Fabian Frederick , linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH 10/28] ext4: change ext4_xattr_inode_iget() signature Date: Wed, 31 May 2017 01:14:59 -0700 Message-Id: <20170531081517.11438-10-tahsin@google.com> X-Mailer: git-send-email 2.13.0.219.gdb65acc882-goog In-Reply-To: <20170531081517.11438-1-tahsin@google.com> References: <20170531081517.11438-1-tahsin@google.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In general, kernel functions indicate success/failure through their return values. This function returns the status as an output parameter and reserves the return value for the inode. Make it follow the general convention. Signed-off-by: Tahsin Erdogan --- fs/ext4/xattr.c | 73 +++++++++++++++++++++++++++++++-------------------------- fs/ext4/xattr.h | 2 -- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 13daf634244b..d9477d01be9b 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -312,40 +312,47 @@ ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size) return 0; } -struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, int *err) +static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, + struct inode **ea_inode) { - struct inode *ea_inode = NULL; + struct inode *inode; + int err; + + inode = ext4_iget(parent->i_sb, ea_ino); + if (IS_ERR(inode)) { + err = PTR_ERR(inode); + ext4_error(parent->i_sb, "error while reading EA inode %lu " + "err=%d", ea_ino, err); + return err; + } - ea_inode = ext4_iget(parent->i_sb, ea_ino); - if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) { - int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0; + if (is_bad_inode(inode)) { ext4_error(parent->i_sb, "error while reading EA inode %lu " - "/ %d %d", ea_ino, rc, is_bad_inode(ea_inode)); - *err = rc != 0 ? rc : -EIO; - return NULL; + "is_bad_inode", ea_ino); + err = -EIO; + goto error; } - if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino || - ea_inode->i_generation != parent->i_generation) { + if (EXT4_XATTR_INODE_GET_PARENT(inode) != parent->i_ino || + inode->i_generation != parent->i_generation) { ext4_error(parent->i_sb, "Backpointer from EA inode %lu " - "to parent invalid.", ea_ino); - *err = -EINVAL; + "to parent is invalid.", ea_ino); + err = -EINVAL; goto error; } - if (!(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) { + if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) { ext4_error(parent->i_sb, "EA inode %lu does not have " "EXT4_EA_INODE_FL flag set.\n", ea_ino); - *err = -EINVAL; + err = -EINVAL; goto error; } - *err = 0; - return ea_inode; - + *ea_inode = inode; + return 0; error: - iput(ea_inode); - return NULL; + iput(inode); + return err; } /* @@ -355,17 +362,17 @@ static int ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer, size_t *size) { - struct inode *ea_inode = NULL; - int err; + struct inode *ea_inode; + int ret; - ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); - if (err) - return err; + ret = ext4_xattr_inode_iget(inode, ea_ino, &ea_inode); + if (ret) + return ret; - err = ext4_xattr_inode_read(ea_inode, buffer, size); + ret = ext4_xattr_inode_read(ea_inode, buffer, size); iput(ea_inode); - return err; + return ret; } static int @@ -868,7 +875,7 @@ int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino) struct inode *ea_inode = NULL; int err; - ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); + err = ext4_xattr_inode_iget(inode, ea_ino, &ea_inode); if (err) return err; @@ -1948,7 +1955,7 @@ static int ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, int credits, struct ext4_xattr_ino_array *lea_ino_array) { - struct inode *ea_inode = NULL; + struct inode *ea_inode; int idx = 0, error = 0; if (lea_ino_array == NULL) @@ -1967,8 +1974,8 @@ ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, return error; } } - ea_inode = ext4_xattr_inode_iget(inode, - lea_ino_array->xia_inodes[idx], &error); + error = ext4_xattr_inode_iget(inode, + lea_ino_array->xia_inodes[idx], &ea_inode); if (error) continue; inode_lock(ea_inode); @@ -2085,7 +2092,7 @@ void ext4_xattr_inode_array_free(struct inode *inode, struct ext4_xattr_ino_array *lea_ino_array) { - struct inode *ea_inode = NULL; + struct inode *ea_inode; int idx = 0; int err; @@ -2093,8 +2100,8 @@ ext4_xattr_inode_array_free(struct inode *inode, return; for (; idx < lea_ino_array->xia_count; ++idx) { - ea_inode = ext4_xattr_inode_iget(inode, - lea_ino_array->xia_inodes[idx], &err); + err = ext4_xattr_inode_iget(inode, + lea_ino_array->xia_inodes[idx], &ea_inode); if (err) continue; /* for inode's i_count get from ext4_xattr_delete_inode */ diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h index e8bef79bdc38..b6ef99d1a061 100644 --- a/fs/ext4/xattr.h +++ b/fs/ext4/xattr.h @@ -161,8 +161,6 @@ extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t); extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int); extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int); -extern struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, - int *err); extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino); extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, struct ext4_xattr_ino_array **array);