Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2616466ybz; Mon, 27 Apr 2020 00:44:37 -0700 (PDT) X-Google-Smtp-Source: APiQypLFDFPqwCPHVPZQMkeF32AskXBtnHtHCkTwECNDw4PqnYt1jJfh8u3oa1KxhNRnK933KSb6 X-Received: by 2002:a50:c112:: with SMTP id l18mr18185128edf.37.1587973476868; Mon, 27 Apr 2020 00:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587973476; cv=none; d=google.com; s=arc-20160816; b=UaU2HnBl1gvh1JndIvT9eWO/SQY2Hg1ZgYqSmB7Z7UawQ5XXX/DTMOD5Q3YAipn4y2 Hh74ozM84U2R6u1IgXs1TtnrT+4YjNfsMmfzCpEtUOkvQGJg+10ER7EMIXI73BGY4P4b Kr8jlOuL+onPuu1Q6LMGMb379nVJkQ6JdTXF1F7ljw3+IvJnk3Yjd0y+KTz3qcGmfx6C Epx4yzfbFlLpO4obbc2xvHRgwA75oR3fncDQYXs0HmPkHtoutJBhHEKZVN7uzJJAneE1 Y9R5863pnu+e+xV2s7uBKhnv1D7ReckW/d+Wv64knhAMMMjkBlrM+bU2hZPs2+ovkNjo Detg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J2ueFYfJbnvHeCjbZWouiTCT/5yxNTxRW64HSkOHS6k=; b=apo+jCnSQ7ybBt2dyUtC+awZtRrICB8ISvfft2nhNEd2Yt5PKJil+XSoPRykARIJ/8 pIG0NAXjZyNcyKPrmk0QldXTu9ZMzkDFRuYcp1jVTH4dFl/3bEsPcpLC2avSXIil/Klg 2cM4hbQCYD1OW1BFbMOYC3XTu+DjBs2ZpZ3DXCCusjyRBlcW+oXwhw7n7vOWcz0vMq6W W7QPJLyXPknng/EEGpu7JwBYlSOcf2LIp50xHYruAGQm3eGV6+BbA+BWdwk3YCuEv0q3 m3S/9UVdY+ZjEk8zudtn5aIPsEp8iYSrVPcp0NLt0mA6Xy8AC8fYpYDKrXz2VPSnQZcG pDWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=vsDvwOEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si6696265ejs.372.2020.04.27.00.44.13; Mon, 27 Apr 2020 00:44:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=vsDvwOEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgD0Hmp (ORCPT + 99 others); Mon, 27 Apr 2020 03:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbgD0Hml (ORCPT ); Mon, 27 Apr 2020 03:42:41 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A93C9C061A10 for ; Mon, 27 Apr 2020 00:42:40 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id u16so19265087wmc.5 for ; Mon, 27 Apr 2020 00:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J2ueFYfJbnvHeCjbZWouiTCT/5yxNTxRW64HSkOHS6k=; b=vsDvwOEJ4ADtwAftYHFSGr7eBIujIoTjebnwYye1XpqKCZSfYnAOH7Cf97R/2uLbnb JBWFiDcW1XLYhlp3+3xx6qpbdMCcCzISQUNLQn5V5r5eVxUwEDL7jeBGpQMzPcWpI+S5 D9Au/BHAZkiwzA/a+CYZBYvVx0yLdfpxoXubCjvQAUcxc/0iYSGepnCTGTQtx0fj/YPM 3xcF1tgHw8rbdb5u8fz0PjvwmjumdZu+YXalSfKfb+PRtbXJYLUPtR8zgzeGUT/bA4UE QNhsXd0HnLuSuR0NAWfTfJJ9NBzya/1L9ejLH/TzbGP/g6yQfD6LTLRvV2lp4a/FFgXc ydQA== 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:mime-version:content-transfer-encoding; bh=J2ueFYfJbnvHeCjbZWouiTCT/5yxNTxRW64HSkOHS6k=; b=CMlvfgrnQWgNjek2krYRkZnskmqL8O5dbK42s97Ba4Ls3+AEYl6JgM9uhCmACXW2CK 0VeG+CxFbjPbuSuSsU8V0G0lq/8ezHJEBRw36IlC0K+a5k+HU7gIqXQmzO2viWAlYzBk 0KoVyhSktHCD1NqCAmvg5x/jh95T2LCkYD/18G1Gm26fifsQa820FFl0OdGtLAhILMid PkTDYcmnVaORjii03LpgQ4zBVqQOsXFXbkuJgMgwCF2kbGovEHo52elDNmjVsa0kwPNr CH6asCoVyXLcu6c2eJaKgdIs1eBdFVX3gfqfDi7n+qxMIhn+mV9ZIrJ8zyJMQdKKDGVB ipgQ== X-Gm-Message-State: AGi0PuZjmwEhtlQjVcSIplfRSfrFIBNZBtxoImqOTFxvkRnknXQlsdl2 dYZH+ObxClZah0bb+FnPzvgayg== X-Received: by 2002:a1c:96c6:: with SMTP id y189mr26153350wmd.106.1587973359410; Mon, 27 Apr 2020 00:42:39 -0700 (PDT) Received: from maco2.ams.corp.google.com (a83-162-234-235.adsl.xs4all.nl. [83.162.234.235]) by smtp.gmail.com with ESMTPSA id x132sm15091658wmg.33.2020.04.27.00.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 00:42:38 -0700 (PDT) From: Martijn Coenen To: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com Cc: narayan@google.com, zezeozue@google.com, kernel-team@android.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, maco@google.com, bvanassche@acm.org, Chaitanya.Kulkarni@wdc.com, jaegeuk@kernel.org, Martijn Coenen Subject: [PATCH v3 5/9] loop: Remove figure_loop_size() Date: Mon, 27 Apr 2020 09:42:18 +0200 Message-Id: <20200427074222.65369-6-maco@android.com> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog In-Reply-To: <20200427074222.65369-1-maco@android.com> References: <20200427074222.65369-1-maco@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function was now only used by loop_set_capacity(), and updating the offset and sizelimit is no longer necessary in that case. Just open code the remaining code in the caller instead. Signed-off-by: Martijn Coenen --- drivers/block/loop.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d0f17ee1e29b..d9a1a7e8b192 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -259,26 +259,6 @@ static void loop_set_size(struct loop_device *lo, loff_t size) set_capacity_revalidate_and_notify(lo->lo_disk, size, false); } -static int -figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit) -{ - int err; - loff_t size = get_size(offset, sizelimit, lo->lo_backing_file); - - err = loop_validate_size(size); - if (err) - return err; - - if (lo->lo_offset != offset) - lo->lo_offset = offset; - if (lo->lo_sizelimit != sizelimit) - lo->lo_sizelimit = sizelimit; - - loop_set_size(lo, size); - - return 0; -} - static inline int lo_do_transfer(struct loop_device *lo, int cmd, struct page *rpage, unsigned roffs, @@ -1566,10 +1546,21 @@ loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) { static int loop_set_capacity(struct loop_device *lo) { + int err; + loff_t size; + if (unlikely(lo->lo_state != Lo_bound)) return -ENXIO; - return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit); + size = get_loop_size(lo, lo->lo_backing_file); + + err = loop_validate_size(size); + if (err) + return err; + + loop_set_size(lo, size); + + return 0; } static int loop_set_dio(struct loop_device *lo, unsigned long arg) -- 2.26.2.303.gf8c07b1a785-goog