From patchwork Fri Mar 1 14:05:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835467 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 88E1B1880 for ; Fri, 1 Mar 2019 14:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 765C12F3DA for ; Fri, 1 Mar 2019 14:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ADCE2F20D; Fri, 1 Mar 2019 14:06:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 A48ED2F1EB for ; Fri, 1 Mar 2019 14:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388690AbfCAOF4 (ORCPT ); Fri, 1 Mar 2019 09:05:56 -0500 Received: from mail-pl1-f169.google.com ([209.85.214.169]:40143 "EHLO mail-pl1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOFz (ORCPT ); Fri, 1 Mar 2019 09:05:55 -0500 Received: by mail-pl1-f169.google.com with SMTP id bj4so11545795plb.7; Fri, 01 Mar 2019 06:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P8HiS/pwCG1KcatP0SEN1rNRrqBk76IDlUChEDsg63o=; b=Yk+uK0pTvlJIIl/MleohfN48KSduy/e9/cYC0gRUiLy4+YEseEYJSRChF7dMnhvFEu XjnUwXgkv7WTQTGdR++5NuB75OAUpviDhsnYbe8lEYebGLH7Ka5nmWAhD3Ha7ylZsqs5 +ruR6bPl7rQCcVUPLHDjQ1h0x9ezSS2HtudijXB5PRVZYRR7BhGlP/yw0hSNuH2wWIgl +pJW/dfnPYm0TsOjdBd6DodkU3mBhlvNxkMcmg1dWX9LOgHvGuo5ottbuWFsuOoWqGQE ZqF8c7bPbDvBFWYcmh+TU8tDCc3ci37Z8jRe/FFj0Wviv/XIjH+fR4k2zxn16+kHnMff E1bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P8HiS/pwCG1KcatP0SEN1rNRrqBk76IDlUChEDsg63o=; b=HjKx1a1xX+b16ZZLG9Cm4gOp5Qz9wEdFy+IN+U4hTMYtlIBxS/a2We/8qjADiLGS+B rk7jQeB1aNMVwTgk7krcENrtT6zZsPYc6FvRKpOduMZembzKdzbveUhkLOeTXFLvhAHp dhcqbziK6xBqwvpe27XbrV2IwaKci41pUK77vwJrHlje4yogiRP+b1IyUiUqFDvV/oWf 71MCU1YlCPjjyQaNmMC8ZcFoOaI5jMPRxlBdlXaCOH636uN0bcQviB/a4EiShEsGAIrF RLa2Kb7BFqDXB214cjBmo9zFZKHR5qdGXJWi/elJa0KVNTpJyVP+KTB91FpPtPlsVp3/ TDHg== X-Gm-Message-State: APjAAAVwrG8meFeKVd+mzp113gstEi6D6Foea+XdI+foN3CIUR7RX8eV HT4G4w+Hhvc6lEuskt5Kkn+uVtie X-Google-Smtp-Source: APXvYqwxX4RmpRe2mCMR7O+yQFtL20x8oKLZTnZ1XLx6Pkz+UlxfFKw0EElxTFz7bYGy056Qyu8hfQ== X-Received: by 2002:a17:902:1101:: with SMTP id d1mr5464458pla.19.1551449154126; Fri, 01 Mar 2019 06:05:54 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.05.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:05:52 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 1/8] fs: add support to change project ID Date: Fri, 1 Mar 2019 23:05:34 +0900 Message-Id: <1551449141-7884-2-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Currently, Filesystem use FS_IOC_FS_SETXATTR ioctl to change project ID of file. However we don't support ioctl on symlink files, and it is desirable to change symlink files' project ID just like uid/gid. This patch try to reuse existed interface fchownat(), use group id to set project ID if flag AT_FCHOWN_PROJID passed in. Signed-off-by: Wang Shilong --- fs/attr.c | 26 ++++++++++++++++++++++++-- fs/open.c | 29 +++++++++++++++++++++++------ fs/quota/dquot.c | 23 +++++++++++++++++++++++ include/linux/fs.h | 3 +++ include/linux/quotaops.h | 9 +++++++++ include/uapi/linux/fcntl.h | 1 + tools/include/uapi/linux/fcntl.h | 1 + 7 files changed, 84 insertions(+), 8 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index d22e8187477f..c6b1c1132c8f 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -85,6 +85,28 @@ int setattr_prepare(struct dentry *dentry, struct iattr *attr) if ((ia_valid & ATTR_GID) && !chgrp_ok(inode, attr->ia_gid)) return -EPERM; + /* + * Project Quota ID state is only allowed to change from within the init + * namespace. Enforce that restriction only if we are trying to change + * the quota ID state. Everything else is allowed in user namespaces. + */ + if ((ia_valid & ATTR_PROJID) && current_user_ns() != &init_user_ns) { + kprojid_t projid; + int rc; + + /* + * Filesystem like xfs does't have ->get_projid hook + * should check permission by themselves. + */ + if (inode->i_sb->dq_op->get_projid) { + rc = inode->i_sb->dq_op->get_projid(inode, &projid); + if (rc) + return rc; + if (!projid_eq(projid, attr->ia_projid)) + return -EPERM; + } + } + /* Make sure a caller can chmod. */ if (ia_valid & ATTR_MODE) { if (!inode_owner_or_capable(inode)) @@ -232,8 +254,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de unsigned int ia_valid = attr->ia_valid; WARN_ON_ONCE(!inode_is_locked(inode)); - - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_PROJID | + ATTR_TIMES_SET)) { if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) return -EPERM; } diff --git a/fs/open.c b/fs/open.c index 0285ce7dbd51..4e58c6ee23b3 100644 --- a/fs/open.c +++ b/fs/open.c @@ -597,7 +597,8 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode) return do_fchmodat(AT_FDCWD, filename, mode); } -static int chown_common(const struct path *path, uid_t user, gid_t group) +static int chown_common(const struct path *path, uid_t user, gid_t group, + bool set_project) { struct inode *inode = path->dentry->d_inode; struct inode *delegated_inode = NULL; @@ -605,9 +606,11 @@ static int chown_common(const struct path *path, uid_t user, gid_t group) struct iattr newattrs; kuid_t uid; kgid_t gid; + kprojid_t projid; uid = make_kuid(current_user_ns(), user); gid = make_kgid(current_user_ns(), group); + projid = make_kprojid(current_user_ns(), (projid_t)group); retry_deleg: newattrs.ia_valid = ATTR_CTIME; @@ -620,13 +623,22 @@ static int chown_common(const struct path *path, uid_t user, gid_t group) if (group != (gid_t) -1) { if (!gid_valid(gid)) return -EINVAL; - newattrs.ia_valid |= ATTR_GID; - newattrs.ia_gid = gid; + if (!set_project) { + newattrs.ia_valid |= ATTR_GID; + newattrs.ia_gid = gid; + } else { + newattrs.ia_valid |= ATTR_PROJID; + newattrs.ia_projid = projid; + } + } else if (set_project) { + return -EINVAL; } if (!S_ISDIR(inode->i_mode)) newattrs.ia_valid |= ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV; inode_lock(inode); + if (set_project) + gid = make_kgid(current_user_ns(), (gid_t) -1); error = security_path_chown(path, uid, gid); if (!error) error = notify_change(path->dentry, &newattrs, &delegated_inode); @@ -645,10 +657,15 @@ int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, struct path path; int error = -EINVAL; int lookup_flags; + bool set_project = false; - if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0) + if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH | + AT_FCHOWN_PROJID)) != 0) goto out; + if (flag & AT_FCHOWN_PROJID) + set_project = true; + lookup_flags = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; if (flag & AT_EMPTY_PATH) lookup_flags |= LOOKUP_EMPTY; @@ -659,7 +676,7 @@ int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, error = mnt_want_write(path.mnt); if (error) goto out_release; - error = chown_common(&path, user, group); + error = chown_common(&path, user, group, set_project); mnt_drop_write(path.mnt); out_release: path_put(&path); @@ -700,7 +717,7 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group) if (error) goto out_fput; audit_file(f.file); - error = chown_common(&f.file->f_path, user, group); + error = chown_common(&f.file->f_path, user, group, false); mnt_drop_write_file(f.file); out_fput: fdput(f); diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fc20e06c56ba..46f39ee87312 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2095,6 +2095,29 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) } transfer_to[GRPQUOTA] = dquot; } + + if (iattr->ia_valid & ATTR_PROJID) { + kprojid_t projid; + + if (!inode->i_sb->dq_op->get_projid) + return -ENOTSUPP; + + ret = inode->i_sb->dq_op->get_projid(inode, &projid); + if (ret) + return ret; + if (!projid_eq(iattr->ia_projid, projid)) { + dquot = dqget(sb, make_kqid_projid(iattr->ia_projid)); + if (IS_ERR(dquot)) { + if (PTR_ERR(dquot) != -ESRCH) { + ret = PTR_ERR(dquot); + goto out_put; + } + dquot = NULL; + } + transfer_to[PRJQUOTA] = dquot; + } + } + ret = __dquot_transfer(inode, transfer_to); out_put: dqput_all(transfer_to); diff --git a/include/linux/fs.h b/include/linux/fs.h index 29d8e2cfed0e..2a878a2b90e3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -191,6 +192,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ #define ATTR_TIMES_SET (1 << 16) #define ATTR_TOUCH (1 << 17) +#define ATTR_PROJID (1 << 18) /* * Whiteout is represented by a char device. The following constants define the @@ -213,6 +215,7 @@ struct iattr { umode_t ia_mode; kuid_t ia_uid; kgid_t ia_gid; + kprojid_t ia_projid; loff_t ia_size; struct timespec64 ia_atime; struct timespec64 ia_mtime; diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index dc905a4ff8d7..84d3aeb43e2c 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -22,6 +22,15 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb) /* i_mutex must being held */ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia) { + if (ia->ia_valid & ATTR_PROJID && inode->i_sb->dq_op->get_projid) { + kprojid_t projid; + int rc; + + rc = inode->i_sb->dq_op->get_projid(inode, &projid); + if (!rc && !projid_eq(projid, ia->ia_projid)) + return true; + } + return (ia->ia_valid & ATTR_SIZE && ia->ia_size != inode->i_size) || (ia->ia_valid & ATTR_UID && !uid_eq(ia->ia_uid, inode->i_uid)) || (ia->ia_valid & ATTR_GID && !gid_eq(ia->ia_gid, inode->i_gid)); diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 6448cdd9a350..712c60d7f727 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -90,5 +90,6 @@ #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ +#define AT_FCHOWN_PROJID 0x40000000 /* Change project ID instead of group id */ #endif /* _UAPI_LINUX_FCNTL_H */ diff --git a/tools/include/uapi/linux/fcntl.h b/tools/include/uapi/linux/fcntl.h index 6448cdd9a350..712c60d7f727 100644 --- a/tools/include/uapi/linux/fcntl.h +++ b/tools/include/uapi/linux/fcntl.h @@ -90,5 +90,6 @@ #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ +#define AT_FCHOWN_PROJID 0x40000000 /* Change project ID instead of group id */ #endif /* _UAPI_LINUX_FCNTL_H */ From patchwork Fri Mar 1 14:05:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835475 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 ABF7B1880 for ; Fri, 1 Mar 2019 14:06:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DB262F1EB for ; Fri, 1 Mar 2019 14:06:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 922622F20D; Fri, 1 Mar 2019 14:06:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 12FBC2F26E for ; Fri, 1 Mar 2019 14:06:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388699AbfCAOF7 (ORCPT ); Fri, 1 Mar 2019 09:05:59 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40254 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOF6 (ORCPT ); Fri, 1 Mar 2019 09:05:58 -0500 Received: by mail-pg1-f194.google.com with SMTP id u9so11500378pgo.7; Fri, 01 Mar 2019 06:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dWZB+q6W6k3q14qYvq1GaOP2EZmB/ZM9cMIANHKAgk4=; b=tU1wb65WuMD5wE6rWsc4MLw2R8YQOYYFA+oB2PqQe0NyxIoIbz8WaxKiJAnBm9TS0L Cho4VAqqbXD0b28VBKrLFlbF93CHV5HU8YJOCGFr2pFX9n87t/5ctxI7U6wGxS7dkSF9 xcdKDzdRyjPClqjF07+CSg/VnhhMnUzzrPTB50ojMXNjIzVyJ+Naepw0jEiQ2641Z9ic iMIuij6ddMhn+BHMwAE9/kC3TwpNK6XemFavDRZ/D65YF1ycyLTEx+3VU1+dUHI/OiG2 yDPCm4feJ/lWaAsDBLAkoOoipVsbbdqkAH/jDTCHi1URM/xWktp0+lJE9Kfhs4FuIa6+ DVDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dWZB+q6W6k3q14qYvq1GaOP2EZmB/ZM9cMIANHKAgk4=; b=mPYeOSH0NazLECYdmK39hYq+gSvsirQyazLixoQrbWjWd6w/T0mZookh/5xbft9yJM nthNLrwH0gjGqzafnYGLXG+kbviNQvO4lj3hfVeZgkNHAiBy45bPRfG3+hf8LCR36xV5 ksBSO3eoAKZ/b/iuC49WBPHOE8VA7PDZOjn82xFw7Kw7xxBt1ip4QtVjvd0jJjf/MoH0 aYf6jecdFBG9PGgB6hMi1riBdrkceaANK88s4/wXFZl3nbOUZFxld0M3w5RCU0x9wOtQ be5E7Z6vLwCcBo0CXr3FHjCS3Sx0xBPASKYsuKKstu6ORRNevgdOP44ghpRwDQ0tSkHm TSVw== X-Gm-Message-State: APjAAAW2UUzHppoVZhobV9UoiKAGpkV3UkANqfWJiJPO1hqgpBsV4KWz r7wZ4PdPS2M1oKNZU0R1w7Wqq4ZH X-Google-Smtp-Source: APXvYqzNd1nxNy+yoPlwDYHBTnB0/p0OgCiyliUIihR1WzV7iQQL36ZDA0RNmEucWkhz8XzfHj4+/g== X-Received: by 2002:a63:6985:: with SMTP id e127mr4978637pgc.101.1551449156746; Fri, 01 Mar 2019 06:05:56 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.05.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:05:55 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 2/8] ext4: support project ID in ext4_setattr() Date: Fri, 1 Mar 2019 23:05:35 +0900 Message-Id: <1551449141-7884-3-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Signed-off-by: Wang Shilong --- fs/ext4/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 34d7e0703cc6..b6c451407dcd 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5537,10 +5537,12 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) return error; } if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) || - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) { + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) || + (ia_valid & ATTR_PROJID && !projid_eq(attr->ia_projid, + EXT4_I(inode)->i_projid))) { handle_t *handle; - /* (user+group)*(old+new) structure, inode write (sb, + /* (user+group+project)*(old+new) structure, inode write (sb, * inode block, ? - but truncate inode update has it) */ handle = ext4_journal_start(inode, EXT4_HT_QUOTA, (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb) + @@ -5567,6 +5569,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) inode->i_uid = attr->ia_uid; if (attr->ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; + if (attr->ia_valid & ATTR_PROJID) + EXT4_I(inode)->i_projid = attr->ia_projid; error = ext4_mark_inode_dirty(handle, inode); ext4_journal_stop(handle); } From patchwork Fri Mar 1 14:05:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835479 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 9C5971880 for ; Fri, 1 Mar 2019 14:06:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9D22F245 for ; Fri, 1 Mar 2019 14:06:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82E892F20D; Fri, 1 Mar 2019 14:06:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 6A4352F25A for ; Fri, 1 Mar 2019 14:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388705AbfCAOGA (ORCPT ); Fri, 1 Mar 2019 09:06:00 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40105 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOGA (ORCPT ); Fri, 1 Mar 2019 09:06:00 -0500 Received: by mail-pf1-f195.google.com with SMTP id h1so11485495pfo.7; Fri, 01 Mar 2019 06:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dNvrqz8W2pGUfo3r5kGYI6TG6CApMjIeNboQwS8ZZkU=; b=exlkfKaa5sFT77GYbt5GRit2amWQuXjrWQmz3S0pewNX5P5YykB2fR5qLAi2JFZHLH YlIVYFkj9Ep6uPQwCc5HkVuPC3BE7wJ/huD3BmsKx7rf3CViH/GLz16pVhCIwKbeJUHx 3uSROEfRI8d6PoAFLHe4+5w5CU/0AwlWGgQ1gqA1H4SE6Hoi1Q+SFm5ZYT18C6CGBjFE CmvMbR3iAcgtavS9n20AEwjyTeuVz5XTggnKGfAVseHuW0qybuPWL6IiUMOC0x/yFv/p egcqN6w9NqIgnM+yppLNv1/e4Yq5sy8pA57amWTFS1xRCaxW7hIlILMw1oqyjq+YdrpD Xupg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dNvrqz8W2pGUfo3r5kGYI6TG6CApMjIeNboQwS8ZZkU=; b=HuqQc+Zzj6+4tjWPJff8u/VDRINIjIh9Dm6orICsf3n21QKrCca3mOhzN9h7k3dtWQ 246+ywOQrV4eh+B7pRc+8AjniV6W5KM+t4lIJv/VyKeBCuNzjAgN7qcdkcxrgy/DDSo5 Kl6d6VmxzbGMhpnuiKwQfozK+C3Nm0bxuhItFKyjhbrj7nnZHTPZ1Qat9LmVpwzuyq2K NglS+f3+vpJQQiPLubxoT7P1aMfQ/Fcn5s5w+pOLpXG5/lqzyIjrnt/aq2U/zvvISSuo QHN36IreUSGRA39UrVKdCuuH4cEtfQub7e0BKD0SpOAoZa83Ad/Y9RUQIzTgKVkjBjFz ZuqA== X-Gm-Message-State: APjAAAU9bXjAxrqFDSqtGw6eCtQ34pRab+jSDMmihLHrJtPupME+YKRC EHeDtYg6LsUVCMStttS3/oh/f9S6 X-Google-Smtp-Source: APXvYqyLaLAUDlXplLOzKyuqdb2QSgRnuNUsPEcmA9Ea68eiHEeuZosC1fFzJBjzU1uif5o8n944Qg== X-Received: by 2002:a65:4243:: with SMTP id d3mr4986129pgq.56.1551449159212; Fri, 01 Mar 2019 06:05:59 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.05.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:05:58 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 3/8] f2fs: support project ID in f2fs_setattr() Date: Fri, 1 Mar 2019 23:05:36 +0900 Message-Id: <1551449141-7884-4-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Signed-off-by: Wang Shilong --- fs/f2fs/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index bba56b39dcc5..8eaca056e857 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -789,7 +789,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) if ((attr->ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) || (attr->ia_valid & ATTR_GID && - !gid_eq(attr->ia_gid, inode->i_gid))) { + !gid_eq(attr->ia_gid, inode->i_gid)) || + (attr->ia_valid & ATTR_PROJID && + !projid_eq(attr->ia_projid, F2FS_I(inode)->i_projid))) { f2fs_lock_op(F2FS_I_SB(inode)); err = dquot_transfer(inode, attr); if (err) { @@ -806,6 +808,8 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) inode->i_uid = attr->ia_uid; if (attr->ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; + if (attr->ia_valid & ATTR_PROJID) + F2FS_I(inode)->i_projid = attr->ia_projid; f2fs_mark_inode_dirty_sync(inode, true); f2fs_unlock_op(F2FS_I_SB(inode)); } From patchwork Fri Mar 1 14:05:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835483 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 C67081880 for ; Fri, 1 Mar 2019 14:06:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7D952F1EB for ; Fri, 1 Mar 2019 14:06:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC5972F245; Fri, 1 Mar 2019 14:06:06 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 3C66A2F1EB for ; Fri, 1 Mar 2019 14:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388156AbfCAOGD (ORCPT ); Fri, 1 Mar 2019 09:06:03 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40261 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOGD (ORCPT ); Fri, 1 Mar 2019 09:06:03 -0500 Received: by mail-pg1-f193.google.com with SMTP id u9so11500508pgo.7; Fri, 01 Mar 2019 06:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kiBqi2ro6Was0nH/4v7l9Y+bERxMStLUscG8eBAQsj0=; b=SX+uNue+3ebwSjAa8BHgXn7OCuuRd2C160dkvB2QZ2uv35fJB5FBoVHLB2LcgjC/IK cHVvC6reRpMh9h07ewIGOuvZjaCo2AJSnpWA42M/XJiNt1IdznUL7QeI1zAr9p5R1Qzp 7/xfc1tzsww/vSdr9jPDUzx6LpM7OHiC7gVhL0kv7C49UpKcSHmE3r4XlZaZaazYrsuc TlyVZsHfpz/S2z/buBML3Po/SwNqyevjFPayjYVMYZIyMRixkwgzP8voMVACoWn8iDuU q96kMuMYcAxIGT6jgJkyM3+gFZUhMwvA94uVOXhOA7XaYLSd7IIfH9/x9O5DHX4wxbvZ UZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kiBqi2ro6Was0nH/4v7l9Y+bERxMStLUscG8eBAQsj0=; b=TAXmB5q9tctpFFKPYpxo9sWhvvwkln6vDvHgYWutLaVwsHWGSfnOsAZUu5Tfz6+2hJ dbxLXUguQ7wp+S1U8c0/z/Y1A8Y087Dc3SzSC9gPXKolg7kncJy8CecIFk06CpqJFUW1 Gkd82IZQU2WLriEDjV4U/mYFHdYtJH9a3ckWE7Lo+AWJc89Nv/hryZ7BIHs/OeiwlCG/ fShglYdd51t6KN9SpIhx6R9wrRCy3YLzfpcxHrchSmbSrMqD6pIXVqb8KwzBu0SjbXyq BDiuuI+cn4I/6vs6sOGfZp4/BSNwpFOQXVhtr4L3Irx9VYceIsF/5nDi6P+hu1ZH9yP/ 6vdg== X-Gm-Message-State: APjAAAXBBOifXW8A+qtFIpPRQ0fUsCz5CcH+51HsnB0r8TbvIbeA1dc1 Lf5t6h4VAaqo428hgVKwlRHz9u5L X-Google-Smtp-Source: APXvYqxs83m9fgN5dV2CJgXI6uEH5sRmWf0fOcCVY44WdZLR4d1IKMN20N8XkCRMTTljsoiAjTyYCQ== X-Received: by 2002:a62:be08:: with SMTP id l8mr5659352pff.162.1551449161625; Fri, 01 Mar 2019 06:06:01 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.05.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:06:00 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 4/8] xfs: support project ID in xfs_setattr() Date: Fri, 1 Mar 2019 23:05:37 +0900 Message-Id: <1551449141-7884-5-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Signed-off-by: Wang Shilong --- fs/xfs/xfs_iops.c | 51 +++++++++++++++++++++++++++++++++++++--------- fs/xfs/xfs_linux.h | 10 +++++++++ 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index f48ffd7a8d3e..c10466fe6ed4 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -589,7 +589,8 @@ xfs_vn_change_ok( struct dentry *dentry, struct iattr *iattr) { - struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount; + struct xfs_inode *ip = XFS_I(d_inode(dentry)); + struct xfs_mount *mp = ip->i_mount; if (mp->m_flags & XFS_MOUNT_RDONLY) return -EROFS; @@ -597,6 +598,13 @@ xfs_vn_change_ok( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; + if ((iattr->ia_valid & ATTR_PROJID) && + current_user_ns() != &init_user_ns) { + if (!projid_eq(xfs_projid_to_kprojid(xfs_get_projid(ip)), + iattr->ia_projid)) + return -EPERM; + } + return setattr_prepare(dentry, iattr); } @@ -619,8 +627,10 @@ xfs_setattr_nonsize( int error; kuid_t uid = GLOBAL_ROOT_UID, iuid = GLOBAL_ROOT_UID; kgid_t gid = GLOBAL_ROOT_GID, igid = GLOBAL_ROOT_GID; - struct xfs_dquot *udqp = NULL, *gdqp = NULL; + kprojid_t projid, iprojid; + struct xfs_dquot *udqp = NULL, *gdqp = NULL, *pdqp = NULL; struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL; + struct xfs_dquot *olddquot3 = NULL; ASSERT((mask & ATTR_SIZE) == 0); @@ -632,7 +642,7 @@ xfs_setattr_nonsize( * If the IDs do change before we take the ilock, we're covered * because the i_*dquot fields will get updated anyway. */ - if (XFS_IS_QUOTA_ON(mp) && (mask & (ATTR_UID|ATTR_GID))) { + if (XFS_IS_QUOTA_ON(mp) && (mask & (ATTR_UID|ATTR_GID|ATTR_PROJID))) { uint qflags = 0; if ((mask & ATTR_UID) && XFS_IS_UQUOTA_ON(mp)) { @@ -647,18 +657,25 @@ xfs_setattr_nonsize( } else { gid = inode->i_gid; } + if ((mask & ATTR_PROJID) && XFS_IS_PQUOTA_ON(mp)) { + projid = iattr->ia_projid; + qflags |= XFS_QMOPT_PQUOTA; + } else { + projid = xfs_projid_to_kprojid(xfs_get_projid(ip)); + } /* - * We take a reference when we initialize udqp and gdqp, + * We take a reference when we initialize udqp,gdqp and pdqp, * so it is important that we never blindly double trip on * the same variable. See xfs_create() for an example. */ ASSERT(udqp == NULL); ASSERT(gdqp == NULL); + ASSERT(pdqp == NULL); error = xfs_qm_vop_dqalloc(ip, xfs_kuid_to_uid(uid), xfs_kgid_to_gid(gid), - xfs_get_projid(ip), - qflags, &udqp, &gdqp, NULL); + xfs_kprojid_to_projid(projid), + qflags, &udqp, &gdqp, &pdqp); if (error) return error; } @@ -673,7 +690,7 @@ xfs_setattr_nonsize( /* * Change file ownership. Must be the owner or privileged. */ - if (mask & (ATTR_UID|ATTR_GID)) { + if (mask & (ATTR_UID|ATTR_GID|ATTR_PROJID)) { /* * These IDs could have changed since we last looked at them. * But, we're assured that if the ownership did change @@ -682,8 +699,10 @@ xfs_setattr_nonsize( */ iuid = inode->i_uid; igid = inode->i_gid; + iprojid = xfs_projid_to_kprojid(xfs_get_projid(ip)); gid = (mask & ATTR_GID) ? iattr->ia_gid : igid; uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid; + projid = (mask & ATTR_PROJID) ? iattr->ia_projid : iprojid; /* * Do a quota reservation only if uid/gid is actually @@ -691,10 +710,11 @@ xfs_setattr_nonsize( */ if (XFS_IS_QUOTA_RUNNING(mp) && ((XFS_IS_UQUOTA_ON(mp) && !uid_eq(iuid, uid)) || - (XFS_IS_GQUOTA_ON(mp) && !gid_eq(igid, gid)))) { + (XFS_IS_GQUOTA_ON(mp) && !gid_eq(igid, gid)) || + (XFS_IS_PQUOTA_ON(mp) && !projid_eq(iprojid, projid)))) { ASSERT(tp); error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, - NULL, capable(CAP_FOWNER) ? + pdqp, capable(CAP_FOWNER) ? XFS_QMOPT_FORCE_RES : 0); if (error) /* out of quota */ goto out_cancel; @@ -704,7 +724,7 @@ xfs_setattr_nonsize( /* * Change file ownership. Must be the owner or privileged. */ - if (mask & (ATTR_UID|ATTR_GID)) { + if (mask & (ATTR_UID|ATTR_GID|ATTR_PROJID)) { /* * CAP_FSETID overrides the following restrictions: * @@ -741,6 +761,15 @@ xfs_setattr_nonsize( ip->i_d.di_gid = xfs_kgid_to_gid(gid); inode->i_gid = gid; } + if (!projid_eq(iprojid, projid)) { + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) { + ASSERT(mask & ATTR_PROJID); + ASSERT(pdqp); + olddquot3 = xfs_qm_vop_chown(tp, ip, + &ip->i_pdquot, pdqp); + } + xfs_set_projid(ip, xfs_kprojid_to_projid(projid)); + } } if (mask & ATTR_MODE) @@ -763,8 +792,10 @@ xfs_setattr_nonsize( */ xfs_qm_dqrele(olddquot1); xfs_qm_dqrele(olddquot2); + xfs_qm_dqrele(olddquot3); xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); if (error) return error; diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index edbd5a210df2..80f5ea32823d 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -191,6 +191,16 @@ static inline kgid_t xfs_gid_to_kgid(uint32_t gid) return make_kgid(&init_user_ns, gid); } +static inline uint32_t xfs_kprojid_to_projid(kprojid_t projid) +{ + return from_kprojid(&init_user_ns, projid); +} + +static inline kprojid_t xfs_projid_to_kprojid(uint32_t projid) +{ + return make_kprojid(&init_user_ns, projid); +} + static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev) { return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); From patchwork Fri Mar 1 14:05:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835487 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 1E59F1880 for ; Fri, 1 Mar 2019 14:06:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F6262F1EB for ; Fri, 1 Mar 2019 14:06:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03D972F25A; Fri, 1 Mar 2019 14:06:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 210252F245 for ; Fri, 1 Mar 2019 14:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387869AbfCAOGG (ORCPT ); Fri, 1 Mar 2019 09:06:06 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37739 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOGG (ORCPT ); Fri, 1 Mar 2019 09:06:06 -0500 Received: by mail-pg1-f193.google.com with SMTP id q206so11506265pgq.4; Fri, 01 Mar 2019 06:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=csWCm9wcihuFFL4oUEGmYUPt6om3ctC29q/OFYjhErk=; b=bwMkidqD6m5h/zOFkwkGPoK7AvAU84RKMKIz7CKeP2TRDv3BdjKH8nnRl0SVBmIFGR cjHWcbAMH8vCKY/SpvhD2TFi2r5/32QH4oIJgK2IxnamqlNkaqmLa2mcF4wg+5kdEeAt QCpbjkmDsR0LQhuYbY3CycDzsSKv04bnIQHp+TBHLuDRs55mE6nwd3Ioor3XAHR62+3e 3ZmMEnA1QRZ01x2TPzFO8Q5JJm9NxCkEqSvjprkSzGftQAkVCXZK8VFLstIrrz1KXzOX zquVBGre5Qf+JK545vfw4Uvq3bBmnnG9T9cJzyP5NRCs2vrOcQOUQ5WevFiERGRjhQja cKtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=csWCm9wcihuFFL4oUEGmYUPt6om3ctC29q/OFYjhErk=; b=YdgUE+ot128CYbWJQaEIiCYYcSTT0zOjsO2T+vcfFxyuWqU6gEkmPN4oqLy53oEmRD OGgmTE0uQyFq2o72ntTsyEa/YVsIBkiW/bu6Ko/psw3OUWmSdEAAn6Z+oER9IEjKEwnF SSkktNqlqXeQTLB894LnddDxY0XXKnIHYRP2ZQ5+anwrfzB1PloTdzWOQEWg3upjYzkH L6F9jms6LWElMwZrdnTCZBVAPK4lwsvjlSe+RofzGq2CD1LXqNyuri0YyLoAS2YGVnSI 1vCeRPS7qCOItuVcunu3eJSSJ1y2yeuWaWM2UdSbujxNZbvldvWlQvWO985hDKK5KvXn a3CA== X-Gm-Message-State: AHQUAubhlX+rem6fcXvM0iIyZxzPjaQ4iU7vTMk6pzuOemHRTm2bP4Zk F4VKWXI/yWMRJDm26bNPFJcPb4P/ X-Google-Smtp-Source: AHgI3IboBpcdD5M0lYdeSrL6Z5y9WAduUlI23iLXpgtGfPDBkrRvf+2Oz1kj+RJzL4YffpHKwpp9Kg== X-Received: by 2002:a62:6d81:: with SMTP id i123mr5647563pfc.235.1551449164026; Fri, 01 Mar 2019 06:06:04 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.06.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:06:03 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 5/8] fs: add project support to statx Date: Fri, 1 Mar 2019 23:05:38 +0900 Message-Id: <1551449141-7884-6-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Extend statx to support project ID and inherit attribute. Signed-off-by: Wang Shilong --- fs/stat.c | 1 + include/linux/stat.h | 2 ++ include/uapi/linux/stat.h | 8 ++++++-- tools/include/uapi/linux/stat.h | 8 ++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index adbfcd86c81b..82d855c4647c 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -551,6 +551,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_rdev_minor = MINOR(stat->rdev); tmp.stx_dev_major = MAJOR(stat->dev); tmp.stx_dev_minor = MINOR(stat->dev); + tmp.stx_projid = (u32)from_kprojid(&init_user_ns, stat->projid); return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; } diff --git a/include/linux/stat.h b/include/linux/stat.h index 765573dc17d6..72c9d2ab5343 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -18,6 +18,7 @@ #include #include #include +#include #define KSTAT_QUERY_FLAGS (AT_STATX_SYNC_TYPE) @@ -40,6 +41,7 @@ struct kstat { dev_t rdev; kuid_t uid; kgid_t gid; + kprojid_t projid; loff_t size; struct timespec64 atime; struct timespec64 mtime; diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 7b35e98d3c58..56d35a2cbd0c 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -123,7 +123,9 @@ struct statx { __u32 stx_dev_major; /* ID of device containing file [uncond] */ __u32 stx_dev_minor; /* 0x90 */ - __u64 __spare2[14]; /* Spare space for future expansion */ + __u32 stx_projid; /* Project ID of file */ + __u32 __spare1[1]; + __u64 __spare2[13]; /* Spare space for future expansion */ /* 0x100 */ }; @@ -148,7 +150,8 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ +#define STATX_PROJID 0x00001000U /* Want/Got stx_projid */ +#define STATX_ALL 0x00001fffU /* All currently supported flags */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* @@ -170,5 +173,6 @@ struct statx { #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ +#define STATX_ATTR_PROJINHERIT 0x00002000 /* [I] File project inherit is set */ #endif /* _UAPI_LINUX_STAT_H */ diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 7b35e98d3c58..21b542b3b061 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -123,7 +123,9 @@ struct statx { __u32 stx_dev_major; /* ID of device containing file [uncond] */ __u32 stx_dev_minor; /* 0x90 */ - __u64 __spare2[14]; /* Spare space for future expansion */ + __u32 stx_projid; /* Project ID of file */ + __u32 __spare1[1]; + __u64 __spare2[13]; /* Spare space for future expansion */ /* 0x100 */ }; @@ -148,7 +150,8 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ +#define STATX_PROJID 0x00001000U /* Want/Got stx_projid */ +#define STATX_ALL 0x00001fffU /* All currently supported flags */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* @@ -170,5 +173,6 @@ struct statx { #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ +#define STATX_ATTR_PROJINHERIT 0x00002000 /* [I] File project inherit is set */ #endif /* _UAPI_LINUX_STAT_H */ From patchwork Fri Mar 1 14:05:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835495 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 6A13F922 for ; Fri, 1 Mar 2019 14:06:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C1202F1EB for ; Fri, 1 Mar 2019 14:06:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 505982F1EC; Fri, 1 Mar 2019 14:06:14 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 8EC592F20D for ; Fri, 1 Mar 2019 14:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388181AbfCAOGJ (ORCPT ); Fri, 1 Mar 2019 09:06:09 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40269 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387836AbfCAOGH (ORCPT ); Fri, 1 Mar 2019 09:06:07 -0500 Received: by mail-pg1-f195.google.com with SMTP id u9so11500589pgo.7; Fri, 01 Mar 2019 06:06:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8M7ToG3O1S9sqar8nQDsp8+aMrMtLN5hbYhPmE6LHpQ=; b=tnMY0d9zmNppFPAIaNz7KSLA3lDh0TnUSMuUH8EBbMjRa5x3BSi7rFqifWUkuMJdvt DSNek2cAyLSIIMCUEIoausZJYK1vbAKJeLyUdmGOmNszmD0vf/bZQx12+6uqUPJNoDll 2uoXQAJRxVQ6wVCjdg0stT8m/bp/0qepkS9cjE4S38el5LWjNlwkjO3Vp7QdM8Ub4mhT nnk/pFbAiM7qupaa4RZUToZERzbuBDuBTsCwm9aJS6IMvIwujh5oGVqk1Rmn3jERoL7y OsWelAswjqRRDn+G8rmBILzmiMaN5upPCknsdBuos5WkchzgTpCt3j5Sz2Qn7/mWn7WU xkmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8M7ToG3O1S9sqar8nQDsp8+aMrMtLN5hbYhPmE6LHpQ=; b=G23ZqzqyZl6rsQ21RRq/8VktFK0mi4AAlF4xb3OAC9VJQYN8sOvg/uMZDbA28XV87Q ch6Vo4udTwb/lQwc5iXa0UEGW2xcIQZ5hFZSwh6Qv7fzI9F0ESufbMqY0wpojYCKORSk pozYRHl0cXyNI80xo3MWk4gMMQ3qT1tbI/mSg0l6sBe3kV1kLtGzABv2FkHjZvT+pSQo gejpUkN0fNJEgr7SlOTLDQvTKklQdrO2T3zKeSJtSdGWA61aVVMFjJeQPhlgghSR+yu8 E1uZXUjEFs39C46zwpcn8ydlCXF+g0Drdr1fOOfSR80HwEGyhRGc5EEvKj2xXRCorCbj Olpg== X-Gm-Message-State: AHQUAuZr4e7ZdKN3zyd+PR3RtpHBS/KCEdOMYCj9RzM3KKjaNSxAV9zh fQfcHf8mPS//kl8LDQ3OL93wViPQ X-Google-Smtp-Source: APXvYqw4ZE8cAUcw/WLaL+uRKDHZL7AMHmapDLx3UASq2zVCYm80LC8mSMTCQpBFLe2G60UuMykRyQ== X-Received: by 2002:a62:61c4:: with SMTP id v187mr5553885pfb.133.1551449166402; Fri, 01 Mar 2019 06:06:06 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.06.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:06:05 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 6/8] ext4: support project in ext4_getattr() Date: Fri, 1 Mar 2019 23:05:39 +0900 Message-Id: <1551449141-7884-7-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Signed-off-by: Wang Shilong --- fs/ext4/inode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index b6c451407dcd..cd7b3f997c3b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5703,6 +5703,8 @@ int ext4_getattr(const struct path *path, struct kstat *stat, struct ext4_inode_info *ei = EXT4_I(inode); unsigned int flags; + stat->projid = ei->i_projid; + if (EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) { stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = ei->i_crtime.tv_sec; @@ -5720,12 +5722,15 @@ int ext4_getattr(const struct path *path, struct kstat *stat, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & EXT4_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; + if (flags & EXT4_PROJINHERIT_FL) + stat->attributes |= STATX_ATTR_PROJINHERIT; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP); + STATX_ATTR_NODUMP | + STATX_ATTR_PROJINHERIT); generic_fillattr(inode, stat); return 0; From patchwork Fri Mar 1 14:05:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835497 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 743C5922 for ; Fri, 1 Mar 2019 14:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 665102F1EB for ; Fri, 1 Mar 2019 14:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A8D12F20D; Fri, 1 Mar 2019 14:06:15 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 16BFC2F1EB for ; Fri, 1 Mar 2019 14:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388032AbfCAOGM (ORCPT ); Fri, 1 Mar 2019 09:06:12 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42522 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbfCAOGJ (ORCPT ); Fri, 1 Mar 2019 09:06:09 -0500 Received: by mail-pg1-f193.google.com with SMTP id b2so11501046pgl.9; Fri, 01 Mar 2019 06:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5ZOo25C1X8MHB6X+yY67EB2Q2uI08yHOFb+79kFGpJY=; b=r3lqbvQA/d4kIxnHqjsA46pRTNiHnLsDWuoCZ0zAqWo351hyHV9IIlyY6+dvZH7WTz fuf/AfX1guPBIYCuVwFdLPzAkQWCbDG1/XIGbSiv2MnBEfZqJr8YQDpHZ3Cm9wB5glOh 76E4UkJpBKy/1oG8YZUeQaXKmmCbHywWG/Y+ojMORct1cV75NYRUKFjTYtieLn8RsDLF RcxHFx5ZcedKl/VVoAtU+DUb0sFsED+Q8O9LVARX0RNiphSAqOty0GQR0Gk6Sr5IaqR5 0HXirqFrckJDpK9STXvZonrp1nsPSk2ObsEC79mOmBtvRTKbYx4EzLHnvQRsyVEimOee s7Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5ZOo25C1X8MHB6X+yY67EB2Q2uI08yHOFb+79kFGpJY=; b=Ixhoa2dFJ5EnuF76wpWyGCeTr8Ukb2a3FmqoC+6+PV38S6XaXIrBrBj43UQW+vlhqV 6MWXGI7XiqhV5lWNFSpxY8Yjgbz4mZpFxLzae8vdG+qT8tcAjTIWTbrvT2Rf9isyiN6E oglmStqMIZ7394dJzSi5AX2WzT2y+GJYlIZK0uwKDoUAkG/odIlPPJqFjrDMYxk+ZI9c hzl06dxVgwkthqt40xdDLBl3oGJOLXgVazYNCf4bTx834BWRUi2OM7VwJwBpQTFBj1is AamfN+FnD9E/ror6CLN4f0BIDAnKYii7uXtvY2D74MpuZTHbiqaYmOY1z7IMMVf/Im3z w+cQ== X-Gm-Message-State: AHQUAubWIJ6en1/Yxl8SVGd1BpUD8Kl8Q1eyJqlqv76z05WPom+IhzUH +RyAasIyxkyQkXG6NYGFJKC+1bp7 X-Google-Smtp-Source: APXvYqyUZu++7exWaPKHL4xSlOddzvHNCEV0P6JJJ4IFKeKX+Of/yHIW/rRHbQDQX/uk3rDUiYoEPw== X-Received: by 2002:aa7:8150:: with SMTP id d16mr5773209pfn.172.1551449168800; Fri, 01 Mar 2019 06:06:08 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.06.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:06:08 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 7/8] f2fs: support project in f2fs_getattr() Date: Fri, 1 Mar 2019 23:05:40 +0900 Message-Id: <1551449141-7884-8-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Signed-off-by: Wang Shilong --- fs/f2fs/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 8eaca056e857..2db5883cc1b0 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -705,6 +705,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat, stat->btime.tv_sec = fi->i_crtime.tv_sec; stat->btime.tv_nsec = fi->i_crtime.tv_nsec; } + stat->projid = fi->i_projid; flags = fi->i_flags & F2FS_FL_USER_VISIBLE; if (flags & F2FS_APPEND_FL) @@ -717,12 +718,15 @@ int f2fs_getattr(const struct path *path, struct kstat *stat, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & F2FS_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; + if (flags & F2FS_PROJINHERIT_FL) + stat->attributes |= STATX_ATTR_PROJINHERIT; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP); + STATX_ATTR_NODUMP | + STATX_ATTR_PROJINHERIT); generic_fillattr(inode, stat); From patchwork Fri Mar 1 14:05:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 10835501 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 AE68A922 for ; Fri, 1 Mar 2019 14:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0EA62F1EB for ; Fri, 1 Mar 2019 14:06:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9462C2F20D; Fri, 1 Mar 2019 14:06:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 536582F1EB for ; Fri, 1 Mar 2019 14:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387836AbfCAOGQ (ORCPT ); Fri, 1 Mar 2019 09:06:16 -0500 Received: from mail-pf1-f178.google.com ([209.85.210.178]:39327 "EHLO mail-pf1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbfCAOGO (ORCPT ); Fri, 1 Mar 2019 09:06:14 -0500 Received: by mail-pf1-f178.google.com with SMTP id i20so11479617pfo.6; Fri, 01 Mar 2019 06:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rzE52lPnGyt0Q/ORpvyzYDAG9Oki7in7KfRHwtaApSM=; b=fZiu7otecETTH+B+2uMb13Dp9h1u1Ylbn2WZ/H28FKOmw3Y/EKziXNytlk7r+h0O4K Y6sMxaH+1vQU9qz7M+CNCpzznUGv8XJY8R7LwdEbJIKVoNapUCk6NFiLunsIQfPlGplO OXDusnzHoJeNTZWPbkVqxTRBMEYtib+rIwua7uy5a8ba1GS8mkQ81FqNKeRHK32Wm52c iMZ2rJ32L4k/mFcAWIt+ANUBzIDgNcrqZe3wq7sqpmdbo64edbIQySMlD/WqbG5NKyB4 A5wpdt0IlAxsPrnuO/vmbXqYHJg8HElEB6NmSRp+Q5ixYCKchBDs/lcgWVz+z7SUmHBg USKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rzE52lPnGyt0Q/ORpvyzYDAG9Oki7in7KfRHwtaApSM=; b=J+puOOh2lyDyNkF2d5IoM7MWnJfg0AFOjl1oRJ4LdRsJzWOSmEiCTOk4LdF9+waCwt yOJEBhL4cC7ufXIFZ+anMBhvnI0MoiezYkqJJP1RAFxe6+Th2bi75H0us7pTJVuyoDxw E2Ssjkob0qmNddOAvMS+/j6saSvAynvuYfXNMmD1zxOdq1vt2xGdc9UIG3LLb91jL/Y2 yFXCENLiJub+X5qC6R9JgjoasdUIWHN4jkNFKrIvMC+Lerva4F44zogV7YZVNgG8y1Uv 58EJs2JXzC4kh/PODDVEt0W1zONNx7CuC06qC+lxB0v909qsosS+jKFCoLs7zkV3iBVW WuNw== X-Gm-Message-State: APjAAAWzlLXEFQkRlkiJOqSl8r+8TZhNZ0f//orWzSUImlBMincGwPvt kkaV6Dt9AHutbX0M0xkbNCOT0OqX X-Google-Smtp-Source: APXvYqyLDBCTmNmFKZQtVEhrEXO2Z23jBhA+CgOfO2y6lbFtgjaE6GywaSWADPgQsWRlomaErASTjg== X-Received: by 2002:a63:8bc7:: with SMTP id j190mr5038177pge.382.1551449171247; Fri, 01 Mar 2019 06:06:11 -0800 (PST) Received: from localhost.localdomain (fs276ec80e.tkyc203.ap.nuro.jp. [39.110.200.14]) by smtp.gmail.com with ESMTPSA id a184sm12458089pge.68.2019.03.01.06.06.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 06:06:10 -0800 (PST) From: Wang Shilong X-Google-Original-From: Wang Shilong To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: lixi@ddn.com, adilger@dilger.ca, Wang Shilong Subject: [PATCH 8/8] xfs: support project in xfs_getattr() Date: Fri, 1 Mar 2019 23:05:41 +0900 Message-Id: <1551449141-7884-9-git-send-email-wshilong1991@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> References: <1551449141-7884-1-git-send-email-wshilong1991@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong From: Wang Shilong Signed-off-by: Wang Shilong --- fs/xfs/xfs_iops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index c10466fe6ed4..a2f8c0f048cf 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -501,6 +501,7 @@ xfs_vn_getattr( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; + stat->projid = xfs_projid_to_kprojid(xfs_get_projid(ip)); stat->size = XFS_ISIZE(ip); stat->dev = inode->i_sb->s_dev; stat->mode = inode->i_mode; @@ -528,6 +529,8 @@ xfs_vn_getattr( stat->attributes |= STATX_ATTR_APPEND; if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP) stat->attributes |= STATX_ATTR_NODUMP; + if (ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) + stat->attributes |= STATX_ATTR_PROJINHERIT; switch (inode->i_mode & S_IFMT) { case S_IFBLK: