From patchwork Wed Oct 24 10:05:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10654479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4394B13B5 for ; Wed, 24 Oct 2018 10:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26C2C2A755 for ; Wed, 24 Oct 2018 10:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AE0C2A757; Wed, 24 Oct 2018 10:06:15 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7BFDB2A758 for ; Wed, 24 Oct 2018 10:06:14 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9O9wqR6112634; Wed, 24 Oct 2018 10:06:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : message-id : mime-version : cc : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : content-type : content-transfer-encoding : sender; s=corp-2018-07-02; bh=GROx7QS7fnaSIaH821Mo+Fj5i9KpOoqscYVXmMQ8G4Q=; b=W2bPbrVbdl3c+IAXSQQgSDWvc4HNeHVcAEtTV2OmZgXyiA2yreWJ6USUX4Ab8W9c7bt+ pC08zgP+8eVPZuONLaaQpaaZ8Yj9FGoD1DlltBnBtvw+YYUEtxfFFR1qMJolP9myUZUh /JJK9oN09JqEDVA3DRW6Dx/EUaec/GPJma6Eu0ftfgLOOxEfrB+K8cvpYGfgeL1hhLP4 r8XeV42ayb9L8JAn089nQzdep642iB5//J5B22y3R27eD4ziU5w7TxBYHA0/LiaiStiu +8xWaxZAL+a2qlu8KLX2yVCD+nPSCzP3Lpewy+1PTPvZbcGAXCJ1UaP+jwctIw5onwhk Aw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n7usuam4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Oct 2018 10:06:04 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9OA61h1016700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Oct 2018 10:06:01 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFG37-0002vn-F5; Wed, 24 Oct 2018 03:06:01 -0700 Received: from userv0022.oracle.com ([156.151.31.74]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFG2m-0002sL-2J for ocfs2-devel@oss.oracle.com; Wed, 24 Oct 2018 03:05:40 -0700 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9OA5dJL018220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Oct 2018 10:05:39 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9OA5cqj017678; Wed, 24 Oct 2018 10:05:38 GMT Received: from kili.mountain (/129.205.6.86) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Oct 2018 03:05:37 -0700 Date: Wed, 24 Oct 2018 13:05:31 +0300 From: Dan Carpenter To: Mark Fasheh , Andrew Morton Message-ID: <20181024100531.wxdstp77isbyo4rk@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Cc: kernel-janitors@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH RESEND] ocfs2: clean up some data_ac usage X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9055 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810240090 X-Virus-Scanned: ClamAV using ClamSMTP I started looking at this code because of a Smatch false positive: fs/ocfs2/move_extents.c:347 ocfs2_defrag_extent() warn: variable dereferenced before check 'context->data_ac' (see line 304) context->data_ac can't be NULL so I removed the check. I changed the next lines to use "data_ac" instead of "context->data_ac" for consistency. And we don't need to pass "data_ac" to ocfs2_lock_meta_allocator_move_extents() any more so I removed that. Signed-off-by: Dan Carpenter --- It should apply now. fs/ocfs2/move_extents.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index 099016c9644e..9ee89d6816bc 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -160,15 +160,12 @@ static int __ocfs2_move_extent(handle_t *handle, * lock allocators, and reserving appropriate number of bits for * meta blocks and data clusters. * - * in some cases, we don't need to reserve clusters, just let data_ac - * be NULL. */ static int ocfs2_lock_meta_allocator_move_extents(struct inode *inode, struct ocfs2_extent_tree *et, u32 clusters_to_move, u32 extents_to_split, struct ocfs2_alloc_context **meta_ac, - struct ocfs2_alloc_context **data_ac, int extra_blocks, int *credits) { @@ -255,7 +252,6 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, ret = ocfs2_lock_meta_allocator_move_extents(inode, &context->et, *len, 1, &context->meta_ac, - &context->data_ac, extra_blocks, &credits); if (ret) { mlog_errno(ret); @@ -344,10 +340,10 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, mlog_errno(ret); out_commit: - if (need_free && context->data_ac) { + if (need_free) { struct ocfs2_alloc_context *data_ac = context->data_ac; - if (context->data_ac->ac_which == OCFS2_AC_USE_LOCAL) + if (data_ac->ac_which == OCFS2_AC_USE_LOCAL) ocfs2_free_local_alloc_bits(osb, handle, data_ac, new_phys_cpos, new_len); else @@ -629,7 +625,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, ret = ocfs2_lock_meta_allocator_move_extents(inode, &context->et, len, 1, &context->meta_ac, - NULL, extra_blocks, &credits); + extra_blocks, &credits); if (ret) { mlog_errno(ret); goto out;