Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp280915imm; Mon, 21 May 2018 06:05:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosE9muNYrEkRxOWUsMDw4ruVdOMOEJjMr48yf1hynx+7XqICFL/4hDwDM8isD9IfYiPv3v X-Received: by 2002:a65:5607:: with SMTP id l7-v6mr3239465pgs.11.1526907914272; Mon, 21 May 2018 06:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526907914; cv=none; d=google.com; s=arc-20160816; b=qr1bBqqUa3Rfzc/l4N533bi5JQJCaLWiesz32EoBnpLpQUo3w0qAv+Kco7yn1bBVab lc1Bu6D5qVgFcMMo2K3kIxEiW/WEgJJ1jWFhQrlxz/xNy5VFgOfWOqAcvv8YWO5ABIzl zYHbIHqHnzT/I+OWENV2bvP5y173Od3dpm/PKoaxBqRM60vTPG67wFKOjVKjSU1j2oHA NT4N1txajPUcv+aR13kfVni4jcR35V3mEFVep0Ga+b1PKQKiXlNvR4qHoXkjLaMFhkcf W2O2idU8a/1tfsAr6UFMOkcxj8VdpnOZMm4vToBd8zP0inKgtT2htP5anGZ1gCDOp2eA vV5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=vY1+D8dQ0aAZTqk8W2GUwsJI0Oqg+wlw6lwkVIL4sP4=; b=oWHR8ccfIjKOuZL/9iTGsGl/eWL47mihi5pNqS7bNwPz/Qwudi9laQppKeUgE3h0yC dsTnEqf/ibXSuaQnRU4f4tWTg5CTmJ1gNKKG/HU1zY2BardErMruTN4KzKQfj42qFOYo r1p5uYD2KMA9ralvm4+j7E59hpC+mLRiEy5ZPbSDq8lK6ThsWaqRPcXWFEdzzC3UCO8b tbiVKazszeV3NrNuEYRzotVLowKfRS8GheyeoEwtVsUYqVEfAFtvidx6Kq2O/wd34p9w g6LD9UnuCaCO/cw10DcjkQR3Gqd4RuhY/W1xb/uG9u33eyvYwkyR70q0A/UUrfiUfRjP LRsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s204-v6si11166881pgs.164.2018.05.21.06.04.56; Mon, 21 May 2018 06:05:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751682AbeEUNEf convert rfc822-to-8bit (ORCPT + 99 others); Mon, 21 May 2018 09:04:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33300 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751161AbeEUNEc (ORCPT ); Mon, 21 May 2018 09:04:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 401694201B14; Mon, 21 May 2018 13:04:32 +0000 (UTC) Received: from ovpn-12-19.pek2.redhat.com (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB4966B59D; Mon, 21 May 2018 13:04:27 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: [PATCH] ceph: fix st_nlink stat for directories From: "Yan, Zheng" In-Reply-To: <20180521092729.17470-1-lhenriques@suse.com> Date: Mon, 21 May 2018 21:04:23 +0800 Cc: Sage Weil , Ilya Dryomov , Ceph Development , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20180521092729.17470-1-lhenriques@suse.com> To: Luis Henriques X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 21 May 2018 13:04:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 21 May 2018 13:04:32 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'zyan@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 21, 2018, at 17:27, Luis Henriques wrote: > > Currently, calling stat on a cephfs directory returns 1 for st_nlink. > This behaviour has recently changed in the fuse client, as some > applications seem to expect this value to be either 0 (if it's > unlinked) or 2 + number of subdirectories. This behaviour was changed > in the fuse client with commit 67c7e4619188 ("client: use common > interp of st_nlink for dirs"). > > This patch modifies the kernel client to have a similar behaviour. > > Link: https://tracker.ceph.com/issues/23873 > Signed-off-by: Luis Henriques > --- > fs/ceph/inode.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c > index aa7c5a4ff137..6ad66ef8fd66 100644 > --- a/fs/ceph/inode.c > +++ b/fs/ceph/inode.c > @@ -2288,6 +2288,14 @@ int ceph_getattr(const struct path *path, struct kstat *stat, > stat->size = ci->i_files + ci->i_subdirs; > stat->blocks = 0; > stat->blksize = 65536; > + /* > + * Some applications rely on the number of st_nlink > + * value on directories to be either 0 (if unlinked) > + * or 2 + number of subdirectories. > + */ > + if (stat->nlink == 1) > + /* '.' + '..' + subdirs */ > + stat->nlink = 1 + 1 + ci->i_subdirs; > } > } > return err; Applied, thanks. Yan, Zheng