From patchwork Fri Mar 22 16:48:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 10866249 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 B27091515 for ; Fri, 22 Mar 2019 16:48:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98B522A945 for ; Fri, 22 Mar 2019 16:48:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ADE12A947; Fri, 22 Mar 2019 16:48:46 +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,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 56CC22A945 for ; Fri, 22 Mar 2019 16:48:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727637AbfCVQso (ORCPT ); Fri, 22 Mar 2019 12:48:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:43036 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726023AbfCVQsn (ORCPT ); Fri, 22 Mar 2019 12:48:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2486EAD0A; Fri, 22 Mar 2019 16:48:42 +0000 (UTC) From: David Disseldorp To: Ilya Dryomov Cc: ceph-devel@vger.kernel.org, Gregory Farnum , Patrick Donnelly , Jeff Layton , Sage Weil , David Disseldorp Subject: [PATCH 1/3] ceph: clean up ceph.dir.pin vxattr name sizeof() Date: Fri, 22 Mar 2019 17:48:26 +0100 Message-Id: <20190322164828.20510-1-ddiss@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190322173004.12f2a3a3@echidna.suse.de> References: <20190322173004.12f2a3a3@echidna.suse.de> 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 .name_size should use the same string as .name. Signed-off-by: David Disseldorp --- fs/ceph/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 0cc42c8879e9..2cbb9c239183 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -327,7 +327,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = { XATTR_RSTAT_FIELD(dir, rctime), { .name = "ceph.dir.pin", - .name_size = sizeof("ceph.dir_pin"), + .name_size = sizeof("ceph.dir.pin"), .getxattr_cb = ceph_vxattrcb_dir_pin, .exists_cb = ceph_vxattrcb_dir_pin_exists, .flags = VXATTR_FLAG_HIDDEN, From patchwork Fri Mar 22 16:48:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 10866251 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 B07B61515 for ; Fri, 22 Mar 2019 16:48:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97E432A945 for ; Fri, 22 Mar 2019 16:48:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C2ED2A947; Fri, 22 Mar 2019 16:48:48 +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,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 0F6D72A945 for ; Fri, 22 Mar 2019 16:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbfCVQsq (ORCPT ); Fri, 22 Mar 2019 12:48:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:43080 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726023AbfCVQsq (ORCPT ); Fri, 22 Mar 2019 12:48:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 77171AD0A; Fri, 22 Mar 2019 16:48:45 +0000 (UTC) From: David Disseldorp To: Ilya Dryomov Cc: ceph-devel@vger.kernel.org, Gregory Farnum , Patrick Donnelly , Jeff Layton , Sage Weil , David Disseldorp Subject: [PATCH 2/3] ceph: carry snapshot creation time with inodes Date: Fri, 22 Mar 2019 17:48:27 +0100 Message-Id: <20190322164828.20510-2-ddiss@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190322164828.20510-1-ddiss@suse.de> References: <20190322173004.12f2a3a3@echidna.suse.de> <20190322164828.20510-1-ddiss@suse.de> 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 MDS InodeStat v3 wire structures include a trailing snapshot creation time member. Unmarshall this and retain it for a future vxattr. Link: https://tracker.ceph.com/issues/38838 Signed-off-by: David Disseldorp --- fs/ceph/inode.c | 1 + fs/ceph/mds_client.c | 8 ++++++++ fs/ceph/mds_client.h | 1 + fs/ceph/super.h | 1 + 4 files changed, 11 insertions(+) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index e3346628efe2..4a32a62b12c9 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -820,6 +820,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page, dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode, from_kuid(&init_user_ns, inode->i_uid), from_kgid(&init_user_ns, inode->i_gid)); + ceph_decode_timespec64(&ci->i_snap_btime, &iinfo->snap_btime); } if ((new_version || (new_issued & CEPH_CAP_LINK_SHARED)) && diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 21c33ed048ed..a9f2dc266597 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -166,6 +166,13 @@ static int parse_reply_info_in(void **p, void *end, info->dir_pin = -ENODATA; } + /* snapshot birth time, remains zero for v<=2 */ + if (struct_v >= 3) { + ceph_decode_need(p, end, sizeof(info->snap_btime), bad); + ceph_decode_copy(p, &info->snap_btime, + sizeof(info->snap_btime)); + } + *p = end; } else { if (features & CEPH_FEATURE_MDS_INLINE_DATA) { @@ -198,6 +205,7 @@ static int parse_reply_info_in(void **p, void *end, } info->dir_pin = -ENODATA; + /* info->snap_btime remains zero */ } return 0; bad: diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 50385a481fdb..c5f7eca6ce3e 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -69,6 +69,7 @@ struct ceph_mds_reply_info_in { u64 max_bytes; u64 max_files; s32 dir_pin; + struct ceph_timespec snap_btime; }; struct ceph_mds_reply_dir_entry { diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 16c03188578e..59233dce4ef4 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -386,6 +386,7 @@ struct ceph_inode_info { int i_snap_realm_counter; /* snap realm (if caps) */ struct list_head i_snap_realm_item; struct list_head i_snap_flush_item; + struct timespec64 i_snap_btime; struct work_struct i_wb_work; /* writeback work */ struct work_struct i_pg_inv_work; /* page invalidation work */ From patchwork Fri Mar 22 16:48:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 10866253 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 B74A66C2 for ; Fri, 22 Mar 2019 16:48:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DFAE2A945 for ; Fri, 22 Mar 2019 16:48:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9246D2A947; Fri, 22 Mar 2019 16:48:50 +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,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 3042C2A945 for ; Fri, 22 Mar 2019 16:48:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728115AbfCVQst (ORCPT ); Fri, 22 Mar 2019 12:48:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:43092 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726023AbfCVQss (ORCPT ); Fri, 22 Mar 2019 12:48:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E74EFAD4E; Fri, 22 Mar 2019 16:48:46 +0000 (UTC) From: David Disseldorp To: Ilya Dryomov Cc: ceph-devel@vger.kernel.org, Gregory Farnum , Patrick Donnelly , Jeff Layton , Sage Weil , David Disseldorp Subject: [PATCH 3/3] ceph: add ceph.snap.btime vxattr Date: Fri, 22 Mar 2019 17:48:28 +0100 Message-Id: <20190322164828.20510-3-ddiss@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190322164828.20510-1-ddiss@suse.de> References: <20190322173004.12f2a3a3@echidna.suse.de> <20190322164828.20510-1-ddiss@suse.de> 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 The ceph.snap.btime virtual xattr provides the snapshot creation (birth) time in $secs.$nsecs format. Link: https://tracker.ceph.com/issues/38838 Signed-off-by: David Disseldorp --- fs/ceph/xattr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 2cbb9c239183..0bdc7c715a42 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -273,6 +273,19 @@ static size_t ceph_vxattrcb_quota_max_files(struct ceph_inode_info *ci, return snprintf(val, size, "%llu", ci->i_max_files); } +/* snapshots */ +static bool ceph_vxattrcb_snap_btime_exists(struct ceph_inode_info *ci) +{ + return (ci->i_snap_btime.tv_sec != 0 && ci->i_snap_btime.tv_nsec != 0); +} + +static size_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val, + size_t size) +{ + return snprintf(val, size, "%lld.09%ld", ci->i_snap_btime.tv_sec, + ci->i_snap_btime.tv_nsec); +} + #define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name #define CEPH_XATTR_NAME2(_type, _name, _name2) \ XATTR_CEPH_PREFIX #_type "." #_name "." #_name2 @@ -341,6 +354,13 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = { }, XATTR_QUOTA_FIELD(quota, max_bytes), XATTR_QUOTA_FIELD(quota, max_files), + { + .name = "ceph.snap.btime", + .name_size = sizeof("ceph.snap.btime"), + .getxattr_cb = ceph_vxattrcb_snap_btime, + .exists_cb = ceph_vxattrcb_snap_btime_exists, + .flags = VXATTR_FLAG_READONLY, + }, { .name = NULL, 0 } /* Required table terminator */ }; static size_t ceph_dir_vxattrs_name_size; /* total size of all names */ @@ -360,6 +380,13 @@ static struct ceph_vxattr ceph_file_vxattrs[] = { XATTR_LAYOUT_FIELD(file, layout, object_size), XATTR_LAYOUT_FIELD(file, layout, pool), XATTR_LAYOUT_FIELD(file, layout, pool_namespace), + { + .name = "ceph.snap.btime", + .name_size = sizeof("ceph.snap.btime"), + .getxattr_cb = ceph_vxattrcb_snap_btime, + .exists_cb = ceph_vxattrcb_snap_btime_exists, + .flags = VXATTR_FLAG_READONLY, + }, { .name = NULL, 0 } /* Required table terminator */ }; static size_t ceph_file_vxattrs_name_size; /* total size of all names */