From patchwork Fri Nov 10 01:01:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarthak Kukreti X-Patchwork-Id: 163699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp810414vqs; Thu, 9 Nov 2023 17:03:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaaWiqsgdslFpN3+C6wHZpzufqpcf/qcRRGR/0y3h9d8zg/9FHpzU19JPSmSafORnpuRWn X-Received: by 2002:a9d:760f:0:b0:6d3:2d45:3b46 with SMTP id k15-20020a9d760f000000b006d32d453b46mr6485150otl.31.1699578236184; Thu, 09 Nov 2023 17:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699578236; cv=none; d=google.com; s=arc-20160816; b=BvJzvmm8ycYAtzWrRBGsP1t3TI8Ljlqr7emxWXecsSpdvambqoX31k1sP2kZpufMre RIJZRIeCKRiDrpvcmYGtbOvWGqB27m2b0EmEQ6sSIKYE6PV/K5MTDrgM6O85qsN82fyW QMZkxiVSyZzV/NfZgpkp6gmjjcujWCPI07geGxEfa3f0TfIPXMTa7x+Eq086qbJUk5Qj vWXrA64LXCe9w2WmepnfnPaj6vDIvr5pobHHB0WIhWuUn1stXEeQdYW9DUXrfh1bKlbN NmRNmIm1eqy9jaXWewWYQItA9Hg6Qx0KStiq7azx02AbnNVOUr98oMES+LORDgo0tZ17 TLTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oQQfAGVkAKgYf59iXbnKQtwf1SRSbMQhaeMVSM1Y7tg=; fh=uvyAx7WF7teTLMdDqtHL7Ly3nN/4d1cbTJCHuKMmX6c=; b=pWWUEZBP1QABVNOgf21d8AlyUE88bDp0iK9plOWrgpmzF9fUGhaKbYIhrdm7gUbzvy PUDZoAlvDM0ZcmfNZenmlllWrWk0sfgr3+daMidI8/gmwaMEK4MGoL/ucs+nCMBLaHUs dPEzHDKfk7Y9a8s5SSs05WZcg8aNA1m6Ak/1qWR/RGV8NaAeAU0kMKTgwXxZ8PXH8tm6 GnCjFfU9Y6TWNpcc+b9t4PZPB1u6kNN+5Di3h6FSJLp0Mi4HTMfZKUrLmyUz5DV3WHNf X5DBxEgeyzP7t7iz0nUpLPAaaIkiKCScf6hzLzFyIjke0SYQMciqIEBY5EQVzME66Rb8 Xnfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GWrkSSWr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t8-20020a05683022e800b006d645ea12casi143977otc.331.2023.11.09.17.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 17:03:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GWrkSSWr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 01D5E804E8A9; Thu, 9 Nov 2023 17:02:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345556AbjKJBCI (ORCPT + 30 others); Thu, 9 Nov 2023 20:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345585AbjKJBCD (ORCPT ); Thu, 9 Nov 2023 20:02:03 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 895C844A4 for ; Thu, 9 Nov 2023 17:01:55 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-28120aa1c24so1316224a91.0 for ; Thu, 09 Nov 2023 17:01:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699578115; x=1700182915; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oQQfAGVkAKgYf59iXbnKQtwf1SRSbMQhaeMVSM1Y7tg=; b=GWrkSSWrCoK5rd5LUATh/8NA5igPFSS7+EfT2MTFQzFgaUNku1YWSLle0sJE1i5T82 XuaRptn52X738p248UZk0GiJ754Xr8J310YfnNW5Xbs5g4YNW3ktRYrPOUgfCDg8/PEJ MxeaOV+AqGGdlSu0G8m/PSBEautfCt7GN+Fn4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699578115; x=1700182915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oQQfAGVkAKgYf59iXbnKQtwf1SRSbMQhaeMVSM1Y7tg=; b=qRI0uSYTA02/uirVlbRuk7u8irozLyAWybqqRngZJvks6gQ60uI/03Aidw0bsgPEsN 8MLxyUZr1QOTPjOadRSkgRJ5E65RjVi+XpfEEIbM0WsjEK5QwFiWkxPIs80K7yhK2DbE P8JoVY2ncbZjTJMNMZwVGV/xvTae1LMHY15lq3hTH+OGA3pzWKj7mUxc9i2ln+rDe4mW iLS/4Nh/aTgd3DsdWWNRa7WZlHLzOuNztawTiee4ezK4iRAJB9v2lbntXAnX9o86AD4N vvb2ZL+b6fLAgOfaqB5dzEvvbKQBnm2pjv3iYmo2mPuu6iA3JgEWolF2+YWJSCLCoGRx HIhA== X-Gm-Message-State: AOJu0Yx29PJjh8AR+2VTZ1w5xX2Hl734vlf+WEJ8Hm63KXOeb9XMKI1s SLsBVAz7RCT1qiMERa0Kt7F4mA== X-Received: by 2002:a17:90b:4c50:b0:27f:fcc8:9196 with SMTP id np16-20020a17090b4c5000b0027ffcc89196mr3455145pjb.32.1699578114986; Thu, 09 Nov 2023 17:01:54 -0800 (PST) Received: from localhost ([2620:15c:9d:2:e584:25c0:d29c:54c]) by smtp.gmail.com with UTF8SMTPSA id 4-20020a17090a018400b0028098225450sm470634pjc.1.2023.11.09.17.01.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Nov 2023 17:01:54 -0800 (PST) From: Sarthak Kukreti To: dm-devel@lists.linux.dev, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Jens Axboe , Mike Snitzer , "Darrick J . Wong" , Christoph Hellwig , Dave Chinner , Brian Foster , Sarthak Kukreti Subject: [PATCH] loop/010: Add test for mode 0 fallocate() on loop devices Date: Thu, 9 Nov 2023 17:01:39 -0800 Message-ID: <20231110010139.3901150-5-sarthakkukreti@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231110010139.3901150-1-sarthakkukreti@chromium.org> References: <20231110010139.3901150-1-sarthakkukreti@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 09 Nov 2023 17:02:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782136948789650277 X-GMAIL-MSGID: 1782136948789650277 A recent patch series[1] adds support for calling fallocate() in mode 0 on block devices. This test adds a basic sanity test for loopback devices setup on a sparse file and validates that writes to the loopback device succeed, even when the underlying filesystem runs out of space. Signed-off-by: Sarthak Kukreti --- tests/loop/010 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tests/loop/010.out | 2 ++ 2 files changed, 62 insertions(+) create mode 100644 tests/loop/010 create mode 100644 tests/loop/010.out diff --git a/tests/loop/010 b/tests/loop/010 new file mode 100644 index 0000000..091be5e --- /dev/null +++ b/tests/loop/010 @@ -0,0 +1,60 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2023 Google LLC. +# Author: sarthakkukret@google.com (Sarthak Kukreti) +# +# Test if fallocate() on a loopback device provisions space on the underlying +# filesystem and writes on the loop device succeed, even if the lower +# filesystem is filled up. + +. tests/loop/rc + +DESCRIPTION="Loop device fallocate() space provisioning" +QUICK=1 + +requires() { + _have_program mkfs.ext4 +} + +test() { + echo "Running ${TEST_NAME}" + + local mount_dir="$TMPDIR/mnt" + mkdir -p ${mount_dir} + + local image_file="$TMPDIR/img" + truncate -s 1G "${image_file}" + + local loop_device + loop_device="$(losetup -P -f --show "${image_file}")" + + mkfs.ext4 ${loop_device} &> /dev/null + mount -t ext4 ${loop_device} ${mount_dir} + + local provisioned_file="${mount_dir}/provisioned" + truncate -s 200M "${provisioned_file}" + + local provisioned_loop_device + provisioned_loop_device="$(losetup -P -f --show "${provisioned_file}")" + + # Provision space for the file: without provisioning support, this fails + # with EOPNOTSUPP. + fallocate -l 200M "${provisioned_loop_device}" + + # Fill the filesystem, this command will error out with ENOSPC. + local fs_fill_file="${mount_dir}/fill" + dd if=/dev/zero of="${fs_fill_file}" bs=1M count=1024 status=none &>/dev/null + sync + + # Write to provisioned loop device, ensure that it does not run into ENOSPC. + dd if=/dev/zero of="${provisioned_loop_device}" bs=1M count=200 status=none + sync + + # Cleanup. + losetup --detach "${provisioned_loop_device}" + umount "${mount_dir}" + losetup --detach "${loop_device}" + rm "${image_file}" + + echo "Test complete" +} \ No newline at end of file diff --git a/tests/loop/010.out b/tests/loop/010.out new file mode 100644 index 0000000..068c489 --- /dev/null +++ b/tests/loop/010.out @@ -0,0 +1,2 @@ +Running loop/009 +Test complete