From patchwork Mon Jul 9 14:17:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10514707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D9D25600CA for ; Mon, 9 Jul 2018 14:18:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C977928B74 for ; Mon, 9 Jul 2018 14:18:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC13B28B76; Mon, 9 Jul 2018 14:18:24 +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 DF17728B74 for ; Mon, 9 Jul 2018 14:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932738AbeGIOSU (ORCPT ); Mon, 9 Jul 2018 10:18:20 -0400 Received: from mout.gmx.net ([212.227.17.20]:50749 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932651AbeGIOSU (ORCPT ); Mon, 9 Jul 2018 10:18:20 -0400 Received: from localhost.localdomain ([113.116.159.163]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LrZOj-1g5ybA1Aib-013Nry; Mon, 09 Jul 2018 16:18:14 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 1/2] ceph: add d_drop for some error cases in ceph_mknod() Date: Mon, 9 Jul 2018 22:17:30 +0800 Message-Id: <20180709141731.18136-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:93reqtGHiEcahvrOnZT04LMgGmHSAtfD2GifiMvF6Qx/3yoYOGQ JeMIUxY96zY/DChxExQ94trC0sY1F7AQEVoiTtDUxfYDXQMDqLtz9OPwJx6ibaBqwnOUDoX xcwYVUSLWyFzDPrXY6ZCoZB+ORBaz794ThYWiviW8MY57QmISWDEidIhOq8IpNoNs+6PmSq aLj67ee9fhJm/fKMIwa1Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:TeLKJBVDtak=:5uupd1VOHQEpLiTLYRhM2V Y/biAw+w+kj+4pNs2pERFwzDSba6jmEiVTIYSGYYsHifBj8HS+5paE+pFAojJ2OIEyqy+LPkY ITbTC0u8j4qGguoGUhXUxbokI0wwGnlArlLRcMoLhHoAIYQHVXreupKj8oU1/j7nkTSnCk2mn T3PgcHxo/u2XcFpso2xEpIfQAXrOBPDY4LRCFG8M0voSBsgbjLJhc2hHS5LTZC0FOhubk1CuY tSQfGD6IGrdYtOO/XXJUwDD/D0vdoObpfslB6d2PB96eEU5cDgOc4v8WDvrPfFHsCp8hyQKnQ HOFHaYhjDIfCq8MBKiZcpxakLbynI6m/w7nPdLqxZyY/OAlisKt/C3vQBfSCrym9M+27zsgiZ l+npZQ+B++4KVjSMXaSYwLnZB2H9Os5wFSMpps+mrNk97zO8u7ADGrj12ssp60mI2mz3d5Vkw ErlaGJEbgeJvwcTo8z9fe5rIWccLnrWK2q7pksw4lkHujrbtdQ8IxCRA6qH5QPfehjPgvUziY DhwMod5+O7GCfosspfOF2d7dHaHwM0uify00B4n/qdC9wUYpXPKaI2BqVeITz1I6af/bmMHIl 4PKMKueSf5fkAdOKLEZx1GC4Xl9wqEv5xyPwbV4CH9XYWQchIJ4hUEaw5lfDvcV3jbu+tBTew 8nfmeroSRuJfN2wlb87CiYaTbCHh/Oq/XcpcbPO4UQmwyM++kfk/xmxKNK+1ZweKPMHx4aS9O wsWQ1xfrNFE+ixNunYfdtgtVPu+uyEJ46ncYkggMEEDPnp+UEFJb95OqsY0= 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 When file num exceeds quota limit or fails from ceph_per_init_acls() should call d_drop to drop dentry from cache as well. Signed-off-by: Chengguang Xu --- Hello, Sorry, I haven't got resource to fully test this patch, so please review. fs/ceph/dir.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 036ac0f3a393..813c01e8ad05 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -827,19 +827,21 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry, if (ceph_snap(dir) != CEPH_NOSNAP) return -EROFS; - if (ceph_quota_is_max_files_exceeded(dir)) - return -EDQUOT; + if (ceph_quota_is_max_files_exceeded(dir)) { + err = -EDQUOT; + goto out; + } err = ceph_pre_init_acls(dir, &mode, &acls); if (err < 0) - return err; + goto out; dout("mknod in dir %p dentry %p mode 0%ho rdev %d\n", dir, dentry, mode, rdev); req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_MKNOD, USE_AUTH_MDS); if (IS_ERR(req)) { err = PTR_ERR(req); - goto out; + goto out2; } req->r_dentry = dget(dentry); req->r_num_caps = 2; @@ -857,12 +859,14 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry, if (!err && !req->r_reply_info.head->is_dentry) err = ceph_handle_notrace_create(dir, dentry); ceph_mdsc_put_request(req); -out: + if (!err) ceph_init_inode_acls(d_inode(dentry), &acls); - else - d_drop(dentry); +out2: ceph_release_acls_info(&acls); +out: + if (err) + d_drop(dentry); return err; }