From patchwork Fri Sep 7 12:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10592135 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 8BBF55A4 for ; Fri, 7 Sep 2018 12:26:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78E662B16D for ; Fri, 7 Sep 2018 12:26:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CCF02B1A1; Fri, 7 Sep 2018 12:26:11 +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 userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 109572B16D for ; Fri, 7 Sep 2018 12:26:10 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w87COL9g159527; Fri, 7 Sep 2018 12:26:00 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=oeXnofmFTdOelpwZjMhKbyN3kLHZtHC9dhheS5493E4=; b=5mbOtw4ZY46bwgbRx/GN8FrD6W+GQDwKJsRUzFe0dU8g6sE37Hxs9VssFBfxouN9aqKG H5sKv8QZKKslgh8udfEcJ3n+/tWMFgJfyhyD7+ydUiBtg4xtotyybiyu3PcBQ9mHmTb8 jLj/KalIHVrFnP4BOgMHsAQuihwcDCYLa1JhpSjWu5fgeDR52397pobqtu1heONEZneb ITAhiQDYKy5eQ+tBIFmAnNoRklrbzU+quiMHSE0YGXCjqUBcYpHSLnTcyqtnLx4dlRZr RAxah5W797tc3CNzmwnx+E4nG/W+zm71x9CVu/pqKOapVzEmPJpn13l4Y2y/4bQy4Gq3 vg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2m7kdr26bc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Sep 2018 12:26:00 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w87CPu5G028312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 7 Sep 2018 12:25:56 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 1fyFpk-0003wB-3J; Fri, 07 Sep 2018 05:25:56 -0700 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1fyFp6-0003v2-1d for ocfs2-devel@oss.oracle.com; Fri, 07 Sep 2018 05:25:16 -0700 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w87CPFF0011280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Sep 2018 12:25:15 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w87CPEjY026022; Fri, 7 Sep 2018 12:25:14 GMT Received: from kili.mountain (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Sep 2018 05:25:13 -0700 Date: Fri, 7 Sep 2018 15:25:01 +0300 From: Dan Carpenter To: Mark Fasheh Message-ID: <20180907122500.azbll3byq4hdnrlw@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) Cc: kernel-janitors@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH] 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=9008 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1809070126 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 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;