Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3099509rwa; Mon, 22 Aug 2022 21:32:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ImzkJnicl9CEbymNq/UEvkP79bauWT6o2t2zc4qg9NkixLzmDLmcEwmQlpPyW78mrFefO X-Received: by 2002:a05:6a00:893:b0:528:646f:528a with SMTP id q19-20020a056a00089300b00528646f528amr23253737pfj.21.1661229152241; Mon, 22 Aug 2022 21:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661229152; cv=none; d=google.com; s=arc-20160816; b=Ig8XRibSQpRGnKRweV0a7hTtl/RT0mDNusILZryCxiLkyEJfyBfz4kmbraxyzxN2uy rWsPzlnVvu6HL7BlPyjOncMbLrEDMIes3GApwZU9kJnggbwjBgaPVxMfofk1HuMRITEl 7swsd/03l74U3dGl2Hf8FPVnA3qgzRZCQMa3t6hn7KK8rZjsRJFwOdHe0y5Ko8YmjPU3 /D/ieo67UnqwXkWdOluPPCY7S3ufMFseZwgN9gBppPw8wU0RvBKpeF54b/ZQaciOTXDZ cCNI3+1tOZnBU5kq9P2Ul7xzeCqJkX0QHyMcXEy+nLmmWGLNK21t391lwJBfoBBaHYqh oHsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=tsW9Qubr1PtTTYMn36tQKaje9CJLhaJWoU401/ORweU=; b=AYfsRDysN9vIcHzDhHIz8Y9jqjySiWIrbqgG28eA+7BlY+eoa/bu0j65/TYLFQ3wqY 8QS5D53l1U3v1FZAOeZTvcTVRxk53Z29Wns8cLb87OlnnPg0Tcjf+KnOh8bLDGL3iTpr h4iceyaMCqsFTgl7bEuP0uxh0T3pSngF1l461MQks/sQd2kHR2ArcKs9uQ6p7a73R2YP B1xfOvOAzuZSTVsOOO4MrlQ5bvrXo0oFQ/Z7zZDjeFgLOVnO2gXaTLCZbsniQTUnzyWC lWYpJ5PjA5Wn0+GJKHbELGzasY0LfnEv2w92aRiMsmQmf1KCuJnMVY3U4ZLy/NF8pIQQ M4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dYAgj6bb; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170902e5d100b0016a0e4d84b2si16087650plf.570.2022.08.22.21.32.13; Mon, 22 Aug 2022 21:32:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dYAgj6bb; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237641AbiHWEUG (ORCPT + 99 others); Tue, 23 Aug 2022 00:20:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235781AbiHWEUF (ORCPT ); Tue, 23 Aug 2022 00:20:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812BC5E318 for ; Mon, 22 Aug 2022 21:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661228402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=tsW9Qubr1PtTTYMn36tQKaje9CJLhaJWoU401/ORweU=; b=dYAgj6bb4KZgebuRIE8r3PWwjFEFgkb0FpPlt+HvEGY+BKaQ3mrWS5jfT5uwp4pYy5tEsr L1PGH04WYF3a8HwOYiHHeWvvloOpu8dKzc3FBzlimtA3kJZ6HyVLMOLdrTU2pTNOoIGzI4 3MuRPWogdq7cI6pjWxP0TXO/WbiWnj8= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-637-T4vVJ2V-N8K-B6Ia5Sbrgg-1; Tue, 23 Aug 2022 00:16:59 -0400 X-MC-Unique: T4vVJ2V-N8K-B6Ia5Sbrgg-1 Received: by mail-pf1-f199.google.com with SMTP id cg5-20020a056a00290500b0053511889856so5429743pfb.18 for ; Mon, 22 Aug 2022 21:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc; bh=tsW9Qubr1PtTTYMn36tQKaje9CJLhaJWoU401/ORweU=; b=jbBK7q2av4hiwFCppfymZpM45PDI9tY6Ir1LtqVgaZ0OkPc390hEAXZ/aBsRNnZQ/+ to0anZGQPEM9vAAkC7/53bAdcCdzGdeA0RtWfbW94uU0iI3k19gTFvBt9rWmmsys0Mbn LLwhVIxU7bgZ8RT/ZQG0R5Bz3BmMwPxpe6eHaUUN14a5hCSAIFdSOPCnB6iqSlFtQNJ2 SJ8Z+jILPvf+nZ9V+GvYfXv8qEItRwwK2ALqTT79UpGaQQxKzxkss2G3Farr7uApwI2H EBfNKfOjUHYHIYMcJaeQPA2hrO+CRsucd0fzNWBuGDUnHx2NRAS4hUTm0kvyPCclp6YJ 40wg== X-Gm-Message-State: ACgBeo0WCf17c0WkoQM0Z/jrGktd+9RakQb6zrEJVChrxR0JiqSwK/Fe 1X4hQvHVGCuAuyRz3Q62Q02jY3CIqdFlsSueBMV3J/FAfX521AV0c1ZB+DtjS6ff0JlA2yzy7AS 6tsyrt78v5mNmVbxsMgHuwT4X5QhnuiXVfC7zMw== X-Received: by 2002:a63:ea11:0:b0:41d:9296:21e6 with SMTP id c17-20020a63ea11000000b0041d929621e6mr18760872pgi.603.1661228217953; Mon, 22 Aug 2022 21:16:57 -0700 (PDT) X-Received: by 2002:a63:ea11:0:b0:41d:9296:21e6 with SMTP id c17-20020a63ea11000000b0041d929621e6mr18760859pgi.603.1661228217682; Mon, 22 Aug 2022 21:16:57 -0700 (PDT) MIME-Version: 1.0 From: Boyang Xue Date: Tue, 23 Aug 2022 12:16:46 +0800 Message-ID: Subject: [bug report] disk quota exceed after multiple write/delete loops To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Lukas Czerner Content-Type: multipart/mixed; boundary="000000000000ce7bc605e6e0d5f3" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org --000000000000ce7bc605e6e0d5f3 Content-Type: text/plain; charset="UTF-8" On the latest kernel 6.0.0-0.rc2, I find the user quota limit in an ext4 mount is unstable, that after several successful "write file then delete" loops, it will finally fail with "Disk quota exceeded". This bug can be reproduced on at least kernel-6.0.0-0.rc2 and kernel-5.14.0-*, but can't be reproduced on kernel-4.18.0 based RHEL8 kernel. Reproducer (can also be found as the attachment): ``` #!/bin/bash # setup groupadd -f quota_test useradd -g quota_test quota_test_user1 dd if=/dev/null of=ext4_5G.img bs=1G seek=5 lo_dev=$(losetup -f --show ext4_5G.img) mkdir /mntpt mkfs.ext4 -F ext4_5G.img mount -o usrquota ext4_5G.img /mntpt chmod 777 /mntpt quotacheck -u /mntpt setquota -u quota_test_user1 200000 300000 2000 3000 /mntpt quotaon -u /mntpt # test for i in $(seq 1 100); do echo "*** Run#$((i++)) ***" echo "--- Quota before writing file ---"; quota -uv quota_test_user1; echo "--- ---" su - quota_test_user1 -c "dd if=/dev/zero of=/mntpt/test_300m bs=1024 count=300000" || break_flag=1 echo "--- Quota after writing file ---"; quota -uv quota_test_user1; echo "--- ---" rm -f /mntpt/test_300m sleep 10s # in case slow deletion echo "--- Quota after deleting file ---"; quota -uv quota_test_user1; echo "--- ---" [[ $break_flag -eq 1 ]] && break done # cleanup umount /mntpt losetup -D rm -rf ext4_5G.img /mntpt userdel -r quota_test_user1 groupdel quota_test ``` Run log on kernel-6.0.0-0.rc2 ``` (...skip successful Run#[1-2]...) *** Run#3 *** --- Quota before writing file --- Disk quotas for user quota_test_user1 (uid 1003): Filesystem blocks quota limit grace files quota limit grace /dev/loop0 0 200000 300000 0 2000 3000 --- --- dd: error writing '/mntpt/test_300m': Disk quota exceeded 299997+0 records in 299996+0 records out 307195904 bytes (307 MB, 293 MiB) copied, 1.44836 s, 212 MB/s --- Quota after writing file --- Disk quotas for user quota_test_user1 (uid 1003): Filesystem blocks quota limit grace files quota limit grace /dev/loop0 300000* 200000 300000 7days 1 2000 3000 --- --- --- Quota after deleting file --- Disk quotas for user quota_test_user1 (uid 1003): Filesystem blocks quota limit grace files quota limit grace /dev/loop0 0 200000 300000 0 2000 3000 --- --- ``` The kernel in test can be found at https://koji.fedoraproject.org/koji/buildinfo?buildID=2050107 --000000000000ce7bc605e6e0d5f3 Content-Type: application/x-sh; name="test_quota_v01.sh" Content-Disposition: attachment; filename="test_quota_v01.sh" Content-Transfer-Encoding: base64 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