From patchwork Mon Apr 15 10:37:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2444541 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 062793FD1A for ; Mon, 15 Apr 2013 10:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754618Ab3DOKdJ (ORCPT ); Mon, 15 Apr 2013 06:33:09 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:56656 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751717Ab3DOKdI (ORCPT ); Mon, 15 Apr 2013 06:33:08 -0400 X-IronPort-AV: E=Sophos;i="4.87,476,1363104000"; d="scan'208";a="7057547" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 15 Apr 2013 18:30:19 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r3FAWtmx008015; Mon, 15 Apr 2013 18:32:56 +0800 Received: from [127.0.0.1] ([10.167.233.203]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013041518313639-555373 ; Mon, 15 Apr 2013 18:31:36 +0800 Message-ID: <516BD85B.3050508@cn.fujitsu.com> Date: Mon, 15 Apr 2013 18:37:15 +0800 From: Wang Shilong User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Linux Btrfs CC: Arne Jansen , Jan Schmidt Subject: [PATCH RFC] Btrfs: fix confusing edquot happening case X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/04/15 18:31:36, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/04/15 18:31:37, Serialize complete at 2013/04/15 18:31:37 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Step to reproduce: mkfs.btrfs mount dd if=/dev/zero of=//data bs=1M count=10 sync btrfs quota enable btrfs qgroup create 0/5 btrfs qgroup limit 5M 0/5 rm -f //data sync btrfs qgroup show dd if=/dev/zero of=data bs=1M count=1 From the perspective of users, qgroup's referenced or referenced is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation. Signed-off-by: Wang Shilong --- This confusing edquot may also happen after Jan's qgroup rescan has been implemented. --- fs/btrfs/qgroup.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index b44124d..0178223 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) qg = (struct btrfs_qgroup *)(uintptr_t)unode->aux; if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) && - qg->reserved + qg->rfer + num_bytes > + qg->reserved + (signed long long)qg->rfer + num_bytes > qg->max_rfer) { ret = -EDQUOT; goto out; } if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) && - qg->reserved + qg->excl + num_bytes > + qg->reserved + (signed long long)qg->excl + num_bytes > qg->max_excl) { ret = -EDQUOT; goto out;