From patchwork Fri Aug 10 09:57:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10562583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D375F13B4 for ; Fri, 10 Aug 2018 09:58:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C502E2B2FF for ; Fri, 10 Aug 2018 09:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B99F02B305; Fri, 10 Aug 2018 09:58:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DEBF2B2FF for ; Fri, 10 Aug 2018 09:58:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbeHJM2B (ORCPT ); Fri, 10 Aug 2018 08:28:01 -0400 Received: from mout.gmx.net ([212.227.15.15]:33485 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbeHJM2B (ORCPT ); Fri, 10 Aug 2018 08:28:01 -0400 Received: from localhost.localdomain ([220.112.58.66]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LnfuZ-1gOo7G0jzb-00hs52; Fri, 10 Aug 2018 11:58:45 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH] ceph: don't allow cross-quota link Date: Fri, 10 Aug 2018 17:57:57 +0800 Message-Id: <20180810095757.24316-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:ValknmBKwFeAKclmNu84VkKUm+s/R69fqtPVbtmed2t3qi2H7tm iZqy5OPKiKHnObpS09Luy8YCpYs9Wharqp+wFnjsOsmn9DdZLtd4ZdXTuRO3Gy/ECAjF83A ZRYCtzvBd7ojPu+qLc35qM0XZmOIS5IkS/+UhAXJqMvR32KVuoQBoV9cWXlwsfvsKgqtp// +gmlIskxO7ON7oiQmw+cg== X-UI-Out-Filterresults: notjunk:1;V01:K0:AidQboGO4m0=:5sVRRZfd3G9Kb45g7G+luG p/iq6eru2cGuKeIGupuZUMgNzgq7QG14vqSBLGZpKADr17jWHs+cOcxX38iU33V1J3FtiN6b/ JoGJ8pEUUsS8HweZDp5IB+faetkuBiD8Hm67Ucp7vx2URW5GwctnIUYDvm12cjFdsC1p7IQf2 eoyUYfdxk9ftnTpNj9VRXhsvIEP3jUSNnRnylXcYgmmGz2oaNgORuB3itmHe5YBiXGLjCy6Fq 2rOTSDsXGJO0+NLY3PdUTki9ETJsiUTR3Y8EbNAPy5DREFPG3usnEoIOux9cGpM+Md98reB2u fvna2plrm4S2asWkDcFt3VR4yHQhekPbeExKhqepY9lzdCS73zTpgAhS0E00fNQ6W9pW6PBXp R9OVOMY3PYeCPQGv2khFnA9o3t59l+jdcHo8FVm/T/SwHfC5nQCXCMgd+COfXbU+GKbuA6Dif H9JUafs4CGqX7Ro6v9UAPrZ9vPcZDn+XanrE3JsYpWLBjJCCtFMUzy1VPQ89faLI/KZuHDLh/ h5nZSUURgay8gyGXizlkbGEo5dx8ssOgi+LngTbj1bNlRZ9Up4Nv/R1Ecv1Ak8qnSZI537mHB s4QkUfjQhbiF3q4sm38lyLiPE7b1UQ6yKc5SFxlPY2OC2uVfCzbP2YkOds9hLUs6S6maE88F5 LMaS0QDKyQvzFUdev8G3yKOZzyq5gLZJawDDMdfbW046jNUBG3jtCb+ZqmPu+DL3NF1De1hQd u0yAw6l6XxNcyxLUXytKLv9jzHALq4xa/5ARC0k7mSXJie0RLasGA3PXNrE= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we allow making hard link bewteen different quota realms and it may cause inaccurate quota accouting. This patch adds quota realm check when doing hard link. Signed-off-by: Chengguang Xu --- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 82928cea0209..87fa996dbad4 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -993,6 +993,10 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, if (ceph_snap(dir) != CEPH_NOSNAP) return -EROFS; + /* don't allow cross-quota link */ + if (!ceph_quota_is_same_realm(d_inode(old_dentry), dir)) + return -EXDEV; + dout("link in dir %p old_dentry %p dentry %p\n", dir, old_dentry, dentry); req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS);