From patchwork Fri Mar 1 01:30:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Genjian X-Patchwork-Id: 208585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp795323dyb; Thu, 29 Feb 2024 17:34:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5s5Q1zDIdnzya88UQkdnFDEJvugYjSpV8XkKDz/oHl+KZvtugzVpI+XLyg/2ZvbJZk4Adi5fAzWRgSptUQNM2rOZX7g== X-Google-Smtp-Source: AGHT+IGIL6Xr8tpSMsA+0XNP5qIgwHorY3LHDks8CDMzGeMNNQeRf6EfjWYM4Gse9DfrOnpzTKsQ X-Received: by 2002:ac8:5dd0:0:b0:42e:bd48:c77b with SMTP id e16-20020ac85dd0000000b0042ebd48c77bmr199276qtx.46.1709256897160; Thu, 29 Feb 2024 17:34:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709256897; cv=pass; d=google.com; s=arc-20160816; b=JLScyxYGXN3rv1mUM9f8gFDS11DE394t+vB/VpdjACn5/J2+08eaBEH/CW1RqM55Ow GM7NItEgim7N9ed93e68mDSNWDnhOqLIxwCs4wKd7UjDVzr/wG4HsiW0lh0gBPB909ai ez3567M71Hq4nGi0XJfrXHoTRCHuzs5GVWvw2xNxWHoIdjM1E9iWm9dPzUQ1srcvh0gP vFVxFZ93pZtUCrdyg4CL5aTczxyDTC6kQC63dE41eIJLNCO/XrV3j+XWgM0g0KZWru98 0Yx0kxLCr8SLIk4fnvYFzRr44EINVQXWbP8GJ/CliczYUl3sgFpWwGoV7lTx/Qf15LC2 43nQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EqfKZGDvpnWQ+qwyxpLC5/VVhwI3t8YX1f9H+0jPymU=; fh=y2ELCHvW0Kpm6IWuTmBRFEBBCj1aVDO7pHe8x9KTo8s=; b=eyisbPBnvo5s702zD9KSLAc4R1tVkOIs2xEam9e287jdW/om65azhmbkUwfGpX+QsW tUJkvXoXqqz3TTqjmPtFwty5Me+mjjoIyy1HQNVUX17dE1g5aGgmgWMU6o9MfeQT+nwG XL15qaRVJTz8VrgQRgms36+2eRVO9SeoSXe50V+S9sMYwsTIwiSp2iz3zXpN6yRVKLWO sCW5Ef2xPpGeGdVBSs1oit7IT6f+y0dlG92ZGHPjcuYtVmyKOt3vm449+8HlgRUlXBaV oM7zWsS8LAs96Z7SnF9QkS2GuuEJqkO/rtOvhGBZRvuG0yhWuvzh5S++PUrwEwg2ARcp 1Mlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=LNV7gEd4; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-87775-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87775-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id df10-20020a05622a0eca00b0042e3c93b998si2435707qtb.608.2024.02.29.17.34.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 17:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87775-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=LNV7gEd4; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-87775-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87775-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EDBBD1C212D5 for ; Fri, 1 Mar 2024 01:34:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5E0A3A8DA; Fri, 1 Mar 2024 01:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="LNV7gEd4" Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.7]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A24138DC3; Fri, 1 Mar 2024 01:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709256792; cv=none; b=RS/XotqBPd/IO3nAo/iIjQIIeGsxyXyprUKhO2gaZ0NQk9qX7rXu0+uutXpyTTg2OMyAv6Wn4UEJHwvIbTg/oGfPU1wIp7dfH3Jpkp0qY4XVD0SGgSg4WhqvpQ28eA8K0wgpNt+Unqk7sl5mJtbL9aZJBeIYBSgbVrcz8T1M7co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709256792; c=relaxed/simple; bh=//shxWOgs6DUM19ppmRaIyOvk+IKSFn/j4eaP7r+Vgs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I7yze/Wte9hvaRdra7+xwFaJZWgwvB3JKD6vffdiaoHCWDqX2B2Q4nIHGLFKnhG1kleRfOgyrC80t2cDjlub3VG0d0iUnlNGu2cwmnZ5nYcjSnyVSxh3liNr6DHeengLV0DN44ohG5mJbVAPJyyXa29TvOYIXvKujv1BZSWF3d0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=LNV7gEd4; arc=none smtp.client-ip=117.135.210.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=EqfKZ GDvpnWQ+qwyxpLC5/VVhwI3t8YX1f9H+0jPymU=; b=LNV7gEd4lcR0AT8fPpbOh isQfXcqySwZELJK+RkJV1ziIir+AwX7UsmPT28xH64Dqo+1lDj8mwKGttJWpjLJr 1jDiTpXu4BrfwP57HCsD37lZ+ckRHy+eRIUmMm8X/DAzbUYbJS9ywMq31/t4A9dc 1JK62+ID1kKXLEx0a9Gmzg= Received: from localhost.localdomain (unknown [116.128.244.171]) by gzga-smtp-mta-g1-0 (Coremail) with SMTP id _____wDn7+APMOFlZSfbBA--.18054S7; Fri, 01 Mar 2024 09:32:39 +0800 (CST) From: Genjian To: stable@vger.kernel.org Cc: axboe@kernel.dk, stable@kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhanggenjian123@gmail.com, Martijn Coenen , Christoph Hellwig , Genjian Zhang Subject: [PATCH 4.19.y 3/9] loop: Remove sector_t truncation checks Date: Fri, 1 Mar 2024 09:30:22 +0800 Message-Id: <20240301013028.2293831-4-zhanggenjian@126.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240301013028.2293831-1-zhanggenjian@126.com> References: <20240301013028.2293831-1-zhanggenjian@126.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: _____wDn7+APMOFlZSfbBA--.18054S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxAryDKF45WF17Ar4fuFy3Arb_yoW5Gw4xpF sruFy5AayFqFWxWFsFqr4kZFyYg3ZrW343ury7C3409r1YqrnYqFy3AryFgrWktrykZF1Y vws8JFy8ur1UCr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jUYFZUUUUU= X-CM-SenderInfo: x2kd0wxjhqyxldq6ij2wof0z/1tbiHhmUfmV2z7wVDwABsW X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792285760319374096 X-GMAIL-MSGID: 1792285760319374096 From: Martijn Coenen [ Upstream commit 083a6a50783ef54256eec3499e6575237e0e3d53 ] sector_t is now always u64, so we don't need to check for truncation. Signed-off-by: Martijn Coenen Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Genjian Zhang --- drivers/block/loop.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bd94406b90c9..281aefba2a6f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -225,24 +225,20 @@ static void __loop_update_dio(struct loop_device *lo, bool dio) blk_mq_unfreeze_queue(lo->lo_queue); } -static int +static void figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit) { loff_t size = get_size(offset, sizelimit, lo->lo_backing_file); - sector_t x = (sector_t)size; struct block_device *bdev = lo->lo_device; - if (unlikely((loff_t)x != size)) - return -EFBIG; if (lo->lo_offset != offset) lo->lo_offset = offset; if (lo->lo_sizelimit != sizelimit) lo->lo_sizelimit = sizelimit; - set_capacity(lo->lo_disk, x); + set_capacity(lo->lo_disk, size); bd_set_size(bdev, (loff_t)get_capacity(bdev->bd_disk) << 9); /* let user-space know about the new size */ kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE); - return 0; } static inline int @@ -972,10 +968,8 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, !file->f_op->write_iter) lo_flags |= LO_FLAGS_READ_ONLY; - error = -EFBIG; size = get_loop_size(lo, file); - if ((loff_t)(sector_t)size != size) - goto out_unlock; + error = loop_prepare_queue(lo); if (error) goto out_unlock; @@ -1280,10 +1274,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) lo->lo_device->bd_inode->i_mapping->nrpages); goto out_unfreeze; } - if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit)) { - err = -EFBIG; - goto out_unfreeze; - } + figure_loop_size(lo, info->lo_offset, info->lo_sizelimit); } memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE); @@ -1486,7 +1477,9 @@ static int loop_set_capacity(struct loop_device *lo) if (unlikely(lo->lo_state != Lo_bound)) return -ENXIO; - return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit); + figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit); + + return 0; } static int loop_set_dio(struct loop_device *lo, unsigned long arg)