Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp917768rwd; Thu, 8 Jun 2023 09:23:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XWBjULbKzFchsWuWt5xS8PJFkQ4cdA8APej1qAlOWPN4stU4+vMFLvxh/JpI2MLZ8dFRt X-Received: by 2002:a05:6a21:340a:b0:119:38a8:63d2 with SMTP id yn10-20020a056a21340a00b0011938a863d2mr231535pzb.1.1686241396665; Thu, 08 Jun 2023 09:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686241396; cv=none; d=google.com; s=arc-20160816; b=uJ4Qi7jua9EcqmLzLln47lvgk0wXteQ+DX8eFSjAyOwJS47ELUWrwEUpUyUaJlbKAf IqboH7qQenNLc0MMTYAx9TcwlUEf4DEvJwXLUnwsRClsE4VAhYSLVtQYMEik5w4DaXzx khIVl9QDmAz1wPBII7KCHqsuOtrtakwGipF/tHlhg0i8QHm3l0wrgmzBaYEY2+u0HBE8 lA6BYO1gUQWyUJLYx+stuYOJUVYm+bLnWMrU97Zd7/LtRMKAg9UAetqU0L6HfemFQlVw hq+qas3boDZ6rn+7Gwi3BwHKwHTpQCnB25auoTmWo6nAMD5RF6Jt9Bn8+1K4V+XYOLO0 O2bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=RyaR97gkxxeix1gmKAnfIKIlV/8H2Db9pN/XXiJh8ZU=; b=EHt5jcmhtqrzIwcZODKI8vEr0gs3zXdaY5bCIxbRIsyhcSZP/9yQZQHFvVC4icjDLR C8zq5j8/JOM/geQma4hJ1pNqkcVyeSEmVPcNrEXRv28VE+C/d3pDjlWGxXdjxHDwcHIU TZUoaC5dtHXT3V8a9QiSfhsCt7wLvgWQXgVm2GjHDM2WNe0oRgGn+ddbsbSN9GyT3Rcd k84kuAe1afOUqu+Sm4QA1+idvsORsa93WZANYMm+r5sZnL3tXfM8PrKBHoiaGfyYAzay qhaVwS6hWFM9cNLnMgwtBiu/vL0LXMWksMoOgPsdH0ssbULp/uBsiYmC/vpx5EYO/xWV xQpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=PZdVp3en; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 85-20020a630258000000b0053f25281d15si1155044pgc.537.2023.06.08.09.23.02; Thu, 08 Jun 2023 09:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=PZdVp3en; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236666AbjFHPzz (ORCPT + 99 others); Thu, 8 Jun 2023 11:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236355AbjFHPzx (ORCPT ); Thu, 8 Jun 2023 11:55:53 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF73A2D69 for ; Thu, 8 Jun 2023 08:55:23 -0700 (PDT) Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id E4C4D3F33C for ; Thu, 8 Jun 2023 15:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239198; bh=RyaR97gkxxeix1gmKAnfIKIlV/8H2Db9pN/XXiJh8ZU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=PZdVp3enSwiG82cVrHyHYTrredXTYZSmCrmTMUH13vZY9foelMCEhYMYd/R3FhLCG FKdxYYHGel2+NtOmYJySkXPlR9xlxWmLkwXkxikEtPLKO02XicowEdVr2C1tc1+Tal zZYX6Icb6i0uIVTdUNsSnVSjqP2rlFjaR5z2BBbQjej6S5Buy4Fg3Udn+Q+Ar1yrT1 MvFoMBZDfCOgQwv2EXi+kxbKC/ynXkcFav8pJz7th8+XrM8o53MYnBNtCk/5jasB1M L4DJZ3X9xcbKdMoXjOhfLRnWdoKPjLew4k4S+k94LdAQHfy2DX6WZyklqcdt3HKMa2 yTpzVYe9pE0ZA== Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-5595551495aso700181eaf.3 for ; Thu, 08 Jun 2023 08:46:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239198; x=1688831198; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RyaR97gkxxeix1gmKAnfIKIlV/8H2Db9pN/XXiJh8ZU=; b=f5a6tdRU4ghfdVx+HUfh0IxZd1XNBKdFspIO+zz6ozpS2EYJYr6EJQFUTNBJY/KgVP kwAVvY/WtKaH9GIbnZahlJ0mMdPuPPfGh+Txqjjb3D6EJPnAGFwhO2OuJW6b6qN/Dawh SaOBxFZIvnUMmnaYz5WXrMZnjII/VX4s4/fJmaCnenZKjh5Poxm3GGdObFcA9vWdydjO fSmGrxPpP7e8Qa0SSg0BjckdOZbyke8+a2pOGcLlUFeb2QEXQ+95Iseqpmne5BfwWVpk guAl1Jo2mclluH1/Pvl+Nt9z/b9Z6TtFTP+RWzkojnVfp73zfD7FdONZGoCUW60xH4Ib Hl+g== X-Gm-Message-State: AC+VfDwqNLiE7NgCWB0LQysRkbcwEUDfW+2MHJr3ioE1n1HHl21gw/F7 MCjcb9zBVhEROjKq6iHeyFErOkasDdpEIekRvBu7SAOpBdftLCsnO37Wg1xXHgDsjyshyubeH/z t/zI7nHqDOhFkdQQW7qMjaYSaxr7IL56je/YmioGjX7xYqhYEFUXABV8XsQ== X-Received: by 2002:a05:6358:e95:b0:129:cb51:7efe with SMTP id 21-20020a0563580e9500b00129cb517efemr6593620rwg.14.1686239197793; Thu, 08 Jun 2023 08:46:37 -0700 (PDT) X-Received: by 2002:a05:6358:e95:b0:129:cb51:7efe with SMTP id 21-20020a0563580e9500b00129cb517efemr6593615rwg.14.1686239197471; Thu, 08 Jun 2023 08:46:37 -0700 (PDT) MIME-Version: 1.0 References: <20230607180958.645115-1-aleksandr.mikhalitsyn@canonical.com> <20230607180958.645115-12-aleksandr.mikhalitsyn@canonical.com> In-Reply-To: From: Aleksandr Mikhalitsyn Date: Thu, 8 Jun 2023 17:46:26 +0200 Message-ID: Subject: Re: [PATCH v4 11/14] ceph: allow idmapped setattr inode op To: Xiubo Li Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 8, 2023 at 4:50=E2=80=AFAM Xiubo Li wrote: > > > On 6/8/23 02:09, Alexander Mikhalitsyn wrote: > > From: Christian Brauner > > > > Enable __ceph_setattr() to handle idmapped mounts. This is just a matte= r > > of passing down the mount's idmapping. > > > > Cc: Xiubo Li > > Cc: Jeff Layton > > Cc: Ilya Dryomov > > Cc: ceph-devel@vger.kernel.org > > Signed-off-by: Christian Brauner > > [ adapted to b27c82e12965 ("attr: port attribute changes to new types")= ] > > Signed-off-by: Alexander Mikhalitsyn > > --- > > v4: > > - introduced fsuid/fsgid local variables > > v3: > > - reworked as Christian suggested here: > > https://lore.kernel.org/lkml/20230602-vorzeichen-praktikum-f17931= 692301@brauner/ > > --- > > fs/ceph/inode.c | 20 ++++++++++++-------- > > 1 file changed, 12 insertions(+), 8 deletions(-) > > > > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c > > index bcd9b506ec3b..ca438d1353b2 100644 > > --- a/fs/ceph/inode.c > > +++ b/fs/ceph/inode.c > > @@ -2052,31 +2052,35 @@ int __ceph_setattr(struct mnt_idmap *idmap, str= uct inode *inode, > > dout("setattr %p issued %s\n", inode, ceph_cap_string(issued)); > > > > if (ia_valid & ATTR_UID) { > > + kuid_t fsuid =3D from_vfsuid(idmap, i_user_ns(inode), att= r->ia_vfsuid); > > + > > dout("setattr %p uid %d -> %d\n", inode, > > from_kuid(&init_user_ns, inode->i_uid), > > from_kuid(&init_user_ns, attr->ia_uid)); > > if (issued & CEPH_CAP_AUTH_EXCL) { > > - inode->i_uid =3D attr->ia_uid; > > + inode->i_uid =3D fsuid; > > dirtied |=3D CEPH_CAP_AUTH_EXCL; > > } else if ((issued & CEPH_CAP_AUTH_SHARED) =3D=3D 0 || > > - !uid_eq(attr->ia_uid, inode->i_uid)) { > > + !uid_eq(fsuid, inode->i_uid)) { > > req->r_args.setattr.uid =3D cpu_to_le32( > > - from_kuid(&init_user_ns, attr->ia_uid)); > > + from_kuid(&init_user_ns, fsuid)); > > mask |=3D CEPH_SETATTR_UID; > > release |=3D CEPH_CAP_AUTH_SHARED; > > } > > } > > if (ia_valid & ATTR_GID) { > > + kgid_t fsgid =3D from_vfsgid(idmap, i_user_ns(inode), att= r->ia_vfsgid); > > + > > dout("setattr %p gid %d -> %d\n", inode, > > from_kgid(&init_user_ns, inode->i_gid), > > from_kgid(&init_user_ns, attr->ia_gid)); > > if (issued & CEPH_CAP_AUTH_EXCL) { > > - inode->i_gid =3D attr->ia_gid; > > + inode->i_gid =3D fsgid; > > dirtied |=3D CEPH_CAP_AUTH_EXCL; > > } else if ((issued & CEPH_CAP_AUTH_SHARED) =3D=3D 0 || > > - !gid_eq(attr->ia_gid, inode->i_gid)) { > > + !gid_eq(fsgid, inode->i_gid)) { > > req->r_args.setattr.gid =3D cpu_to_le32( > > - from_kgid(&init_user_ns, attr->ia_gid)); > > + from_kgid(&init_user_ns, fsgid)); > > mask |=3D CEPH_SETATTR_GID; > > release |=3D CEPH_CAP_AUTH_SHARED; > > } > > @@ -2241,7 +2245,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct = dentry *dentry, > > if (ceph_inode_is_shutdown(inode)) > > return -ESTALE; > > > > - err =3D setattr_prepare(&nop_mnt_idmap, dentry, attr); > > + err =3D setattr_prepare(idmap, dentry, attr); > > if (err !=3D 0) > > return err; > > > > @@ -2256,7 +2260,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct = dentry *dentry, > > err =3D __ceph_setattr(idmap, inode, attr); > > > > if (err >=3D 0 && (attr->ia_valid & ATTR_MODE)) > > - err =3D posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_= mode); > > + err =3D posix_acl_chmod(idmap, dentry, attr->ia_mode); > > > > return err; > > } Hi Xiubo, > > You should also do 'req->r_mnt_idmap =3D idmap;' for sync setattr request= . > > the setattr will just cache the change locally in client side if the 'x' > caps are issued and returns directly or will set a sync setattr reqeust. Have done in v5: ("ceph: pass idmap to __ceph_setattr") https://lore.kernel.org/lkml/20230608154256.562906-8-aleksandr.mikhalitsyn@= canonical.com/ Kind regards, Alex > > Thanks > > - Xiubo >