From patchwork Tue Jun 19 10:23:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10474015 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 30C5F601D7 for ; Tue, 19 Jun 2018 10:24:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 186FE28B3F for ; Tue, 19 Jun 2018 10:24:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B5EB28B49; Tue, 19 Jun 2018 10:24:34 +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 D0D1228B3F for ; Tue, 19 Jun 2018 10:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937229AbeFSKYa (ORCPT ); Tue, 19 Jun 2018 06:24:30 -0400 Received: from mout.gmx.net ([212.227.15.15]:55925 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755596AbeFSKY3 (ORCPT ); Tue, 19 Jun 2018 06:24:29 -0400 Received: from localhost.localdomain ([122.224.77.194]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MQRWm-1fcsm12N8m-00Tk6h; Tue, 19 Jun 2018 12:24:22 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH] ceph: add retry logic for error -ERANGE in ceph_get_acl() Date: Tue, 19 Jun 2018 18:23:09 +0800 Message-Id: <20180619102309.22464-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:+bQUSfOQqlDnmOFWc7hRr9GlwLbo3KpFkl27O7odzJ4ssVHNtPU 58kkgdH5gz4Jydh547cr+F4pnIraMZbwthoyvrpa33TiDkolaN8P/Pb+spsOSN9MQ2n1VpU c0eKbk+ZXkpdu1gPetW1gcmewK5EkEuWJRV+q2UaSHTbUL4zKy51qX0yCES/EC/Np2hYGqI IsD05NqQsUZuCGbMQdmNg== X-UI-Out-Filterresults: notjunk:1; V01:K0:BwuuVJ7aW6g=:jY80gi8fx3v3p029/qi7Xd LzFVBPUCJl7fmfaosWfhNrSjI4YqalJ8xFfmodIQBJrHtpL3vY/v7zbzgclXL8PKjJFkOMeAX NNIRA6dhNMx0iK1ji9dQ8XHyiylzLYR68lSf5TCMt8OkLPESzSyuIR9Bjjnz6KnD7qRZ9d7ac g5ry3tjv+S+kav8CXHWiBdDwvCiGTI+nsXBijTucrgyhDV2ISIQRVOC9rXkKswbJK1faEtqWF ss78TQl45u7dBtvEThgTfP46Fa72/Fl5zxMM7nsoS9Juw7RgibE99bRvnXDi5f09/aMLEmQXO vounSHSTNnwBfsmNoRvoeeNjeFZs0wy5Ix9b9mg6CewwGNSJbXU0lz9mLUL8V00ogTqzDsj1O 759W5DtlTqy4LrdyWFXdBkXy0yGY0Sk+W7dW7dZvFUvDznM900rxnjNeTRXu7glZCyCjnpncI ZNIVTZI/LdbAaMDn2QGpXaqKtOpG3/m2AfKNukfPuzR0v95Q590QuPBd8ChUwcrtjxNEPz+yt 9D0u/c1c9odBHy9V/xHFb4ZW3VAno4SwFgnxeRXyUyJxle5oXtstnmXItAsApc22Fo+bbEPIN IHexKLzxoGNCUERBLmsmsnp1HD/Tpt6Qs8biFn+JE/DARg9qsrdmFapjgMYVN3ctQzvhc6nJd ZJE6HoC6zm51UQEBj6yMrg+bqaz2ptHV4n32gsDIMgFCiBdZPF6IFSd7IXgJob22ojhkchRmq JufLcd4+xnIutsAbHHWjb0QPXZjm75C3eg/UsqO65z2FePpFRW7/S3D1498= 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 the size of acl extended attribution is larger than pre-allocated value buffer size, we will hit error '-ERANGE' and it's probabaly caused by concurrent get/set acl from different clients. In this case, current logic just sets acl to NULL so that we cannot get proper information but the operation looks successful. This patch adds retry logic for error -ERANGE and return -EIO if fail from retry. Signed-off-by: Chengguang Xu --- fs/ceph/acl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 59cb307b15fb..f8750c09cec3 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -48,6 +48,7 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type) const char *name; char *value = NULL; struct posix_acl *acl; + bool retried = false; switch (type) { case ACL_TYPE_ACCESS: @@ -60,6 +61,7 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type) BUG(); } +retry: size = __ceph_getxattr(inode, name, "", 0); if (size > 0) { value = kzalloc(size, GFP_NOFS); @@ -68,9 +70,16 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type) size = __ceph_getxattr(inode, name, value, size); } + if (size == -ERANGE && !retried) { + retried = true; + kfree(value); + value = NULL; + goto retry; + } + if (size > 0) acl = posix_acl_from_xattr(&init_user_ns, value, size); - else if (size == -ERANGE || size == -ENODATA || size == 0) + else if (size == -ENODATA || size == 0) acl = NULL; else acl = ERR_PTR(-EIO);