From patchwork Wed Aug 31 13:01:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9307187 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 508C1601C0 for ; Wed, 31 Aug 2016 13:02:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4214A28DE4 for ; Wed, 31 Aug 2016 13:02:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36A9F28F23; Wed, 31 Aug 2016 13:02:11 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 91E2B28F27 for ; Wed, 31 Aug 2016 13:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934163AbcHaNCF (ORCPT ); Wed, 31 Aug 2016 09:02:05 -0400 Received: from hr2.samba.org ([144.76.82.148]:31425 "EHLO hr2.samba.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934400AbcHaNBz (ORCPT ); Wed, 31 Aug 2016 09:01:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42627210; h=Message-Id:Date:Cc:To:From; bh=ab7qHowDBzIldAP7+VWFgQUyqriklFe8+Vf78KzOMDE=; b=B4FHuKEwoU8LBWEWYwSP2nALp7WTCqVYPDxAJD9cX71zsLgZAU2etBWACVCDdRA4cJrK2deKg+Bblj03IrPMOY+8OLdAV61UP1fZl8fDT/zfNVAwJcHHVJLHKdyt22XNSAUhPoT3SbFeXzaf+1uxiXISjjU9v4uMzyTGhiqF+vA=; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim) id 1bf59P-0003ib-Fm; Wed, 31 Aug 2016 13:01:55 +0000 From: Jeff Layton To: samba-technical@lists.samba.org Cc: ira@wakeful.net, ceph-devel@vger.kernel.org Subject: [samba RFC PATCH 6/6] vfs:ceph: allow vfs_ceph to set the btime using setattrx Date: Wed, 31 Aug 2016 09:01:14 -0400 Message-Id: <1472648474-3131-7-git-send-email-jlayton@samba.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472648474-3131-1-git-send-email-jlayton@samba.org> References: <1472648474-3131-1-git-send-email-jlayton@samba.org> 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 ...as well as the mtime and atime. Signed-off-by: Jeff Layton --- source3/modules/vfs_ceph.c | 100 ++++++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 33 deletions(-) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index b3c26ad4f4c1..338642e311b9 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -648,6 +648,40 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle, return result; } +static int cephwrap_ntimes(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + struct smb_file_time *ft) +{ + struct ceph_statx stx = { 0 }; + int result; + int mask = 0; + + if (!null_timespec(ft->atime)) { + stx.stx_atime = ft->atime.tv_sec; + stx.stx_atime_ns = ft->atime.tv_nsec; + mask |= CEPH_SETATTR_ATIME; + } + if (!null_timespec(ft->mtime)) { + stx.stx_mtime = ft->mtime.tv_sec; + stx.stx_mtime_ns = ft->mtime.tv_nsec; + mask |= CEPH_SETATTR_MTIME; + } + if (!null_timespec(ft->create_time)) { + stx.stx_btime = ft->create_time.tv_sec; + stx.stx_btime_ns = ft->create_time.tv_nsec; + mask |= CEPH_SETATTR_BTIME; + } + + if (!mask) + return 0; + + result = ceph_setattrx(handle->data, smb_fname->base_name, &stx, mask, 0); + DEBUG(10, ("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname), + ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec, + ft->create_time.tv_sec, result)); + return result; +} + #else /* HAVE_CEPH_STATX */ static int cephwrap_stat(struct vfs_handle_struct *handle, @@ -731,6 +765,39 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle, lp_fake_directory_create_times(SNUM(handle->conn))); return result; } + +static int cephwrap_ntimes(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + struct smb_file_time *ft) +{ + struct utimbuf buf; + int result; + + if (null_timespec(ft->atime)) { + buf.actime = smb_fname->st.st_ex_atime.tv_sec; + } else { + buf.actime = ft->atime.tv_sec; + } + if (null_timespec(ft->mtime)) { + buf.modtime = smb_fname->st.st_ex_mtime.tv_sec; + } else { + buf.modtime = ft->mtime.tv_sec; + } + if (!null_timespec(ft->create_time)) { + set_create_timespec_ea(handle->conn, smb_fname, + ft->create_time); + } + if (buf.actime == smb_fname->st.st_ex_atime.tv_sec && + buf.modtime == smb_fname->st.st_ex_mtime.tv_sec) { + return 0; + } + + result = ceph_utime(handle->data, smb_fname->base_name, &buf); + DEBUG(10, ("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname), + ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec, + ft->create_time.tv_sec, result)); + return result; +} #endif /* HAVE_CEPH_STATX */ static int cephwrap_unlink(struct vfs_handle_struct *handle, @@ -885,39 +952,6 @@ static char *cephwrap_getwd(struct vfs_handle_struct *handle) return SMB_STRDUP(cwd); } -static int cephwrap_ntimes(struct vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - struct smb_file_time *ft) -{ - struct utimbuf buf; - int result; - - if (null_timespec(ft->atime)) { - buf.actime = smb_fname->st.st_ex_atime.tv_sec; - } else { - buf.actime = ft->atime.tv_sec; - } - if (null_timespec(ft->mtime)) { - buf.modtime = smb_fname->st.st_ex_mtime.tv_sec; - } else { - buf.modtime = ft->mtime.tv_sec; - } - if (!null_timespec(ft->create_time)) { - set_create_timespec_ea(handle->conn, smb_fname, - ft->create_time); - } - if (buf.actime == smb_fname->st.st_ex_atime.tv_sec && - buf.modtime == smb_fname->st.st_ex_mtime.tv_sec) { - return 0; - } - - result = ceph_utime(handle->data, smb_fname->base_name, &buf); - DEBUG(10, ("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname), - ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec, - ft->create_time.tv_sec, result)); - return result; -} - static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len) { off_t space_to_write;