[PATCH] vfs_gpfs: Check offline bit only when HSM is configured
Christof Schmitt
cs at samba.org
Fri Sep 4 16:53:11 UTC 2015
On Fri, Sep 04, 2015 at 02:07:31PM +0200, Volker Lendecke wrote:
> Hi, Christof!
>
> On Mon, Aug 31, 2015 at 10:53:51AM -0700, Christof Schmitt wrote:
> > We might also need to look into handling the offline flag better in a
> > later patch, but the current patch should be obvious: Without HSM, files
> > can never be offline, and the queries for the offline flag can be
> > skipped.
>
> Attached find the possibly more general approach.
Yes, this looks good and also handles the case where the offline bit is
required.
> Review&push appreciated!
Reviewed-by: Christof Schmitt <cs at samba.org>
I cannot reach git.samba.org now, so pushing is not possible. I can try
again later.
Christof
> Thanks,
>
> Volker
>
> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de
> From 60951bb73c4f1b79ccc19e638fe401bdd3d3e85c Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Thu, 3 Sep 2015 12:10:35 +0200
> Subject: [PATCH 1/2] vfs_gpfs: Introduce vfs_gpfs_fsp_is_offline
>
> This consolidates a few common calls
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/modules/vfs_gpfs.c | 37 ++++++++++++++++++-------------------
> 1 file changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
> index 3e593e1..f40bba7 100644
> --- a/source3/modules/vfs_gpfs.c
> +++ b/source3/modules/vfs_gpfs.c
> @@ -1955,18 +1955,23 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
> return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
> }
>
> +static bool vfs_gpfs_fsp_is_offline(struct vfs_handle_struct *handle,
> + struct files_struct *fsp)
> +{
> + return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
> +}
> +
> static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
> struct files_struct *fsp)
> {
> - return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
> + return vfs_gpfs_fsp_is_offline(handle, fsp);
> }
>
> static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd,
> files_struct *fsp, const DATA_BLOB *hdr,
> off_t offset, size_t n)
> {
> - if (SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name, &fsp->fsp_name->st))
> - {
> + if (vfs_gpfs_fsp_is_offline(handle, fsp)) {
> errno = ENOSYS;
> return -1;
> }
> @@ -2207,14 +2212,12 @@ static int vfs_gpfs_open(struct vfs_handle_struct *handle,
> struct gpfs_config_data,
> return -1);
>
> - if (config->hsm && !config->recalls) {
> - if (SMB_VFS_IS_OFFLINE(handle->conn, smb_fname, &smb_fname->st))
> - {
> - DEBUG(10, ("Refusing access to offline file %s\n",
> - fsp_str_dbg(fsp)));
> - errno = EACCES;
> - return -1;
> - }
> + if (config->hsm && !config->recalls &&
> + vfs_gpfs_fsp_is_offline(handle, fsp)) {
> + DEBUG(10, ("Refusing access to offline file %s\n",
> + fsp_str_dbg(fsp)));
> + errno = EACCES;
> + return -1;
> }
>
> if (config->syncio) {
> @@ -2229,8 +2232,7 @@ static ssize_t vfs_gpfs_pread(vfs_handle_struct *handle, files_struct *fsp,
> ssize_t ret;
> bool was_offline;
>
> - was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
> - &fsp->fsp_name->st);
> + was_offline = vfs_gpfs_fsp_is_offline(handle, fsp);
>
> ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
>
> @@ -2266,8 +2268,7 @@ static struct tevent_req *vfs_gpfs_pread_send(struct vfs_handle_struct *handle,
> if (req == NULL) {
> return NULL;
> }
> - state->was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
> - &fsp->fsp_name->st);
> + state->was_offline = vfs_gpfs_fsp_is_offline(handle, fsp);
> state->fsp = fsp;
> subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
> n, offset);
> @@ -2317,8 +2318,7 @@ static ssize_t vfs_gpfs_pwrite(vfs_handle_struct *handle, files_struct *fsp,
> ssize_t ret;
> bool was_offline;
>
> - was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
> - &fsp->fsp_name->st);
> + was_offline = vfs_gpfs_fsp_is_offline(handle, fsp);
>
> ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
>
> @@ -2355,8 +2355,7 @@ static struct tevent_req *vfs_gpfs_pwrite_send(
> if (req == NULL) {
> return NULL;
> }
> - state->was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
> - &fsp->fsp_name->st);
> + state->was_offline = vfs_gpfs_fsp_is_offline(handle, fsp);
> state->fsp = fsp;
> subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
> n, offset);
> --
> 1.9.1
>
>
> From 36ed420357029166258e835335c8d8836d84cd4f Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Wed, 2 Sep 2015 13:20:08 +0200
> Subject: [PATCH 2/2] vfs_gpfs: Avoid calling gpfs_is_offline on every i/o
>
> Asks gpfs as long as a file is offline. Once it was reported online once,
> we'll not ask anymore. This assumes that while we have a file open it
> won't be migrated away. This might not *always* be true, but probably
> close enough. And as long as we don't have a proper notification mechanism
> and as long as polling is too expensive, this seems like a good strategy.
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/modules/vfs_gpfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
> index f40bba7..ee4c1f6 100644
> --- a/source3/modules/vfs_gpfs.c
> +++ b/source3/modules/vfs_gpfs.c
> @@ -54,6 +54,10 @@ struct gpfs_config_data {
> bool recalls;
> };
>
> +struct gpfs_fsp_extension {
> + bool offline;
> +};
> +
> static inline unsigned int gpfs_acl_flags(gpfs_acl_t *gacl)
> {
> if (gacl->acl_level == GPFS_ACL_LEVEL_V4FLAGS) {
> @@ -1958,7 +1962,26 @@ static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
> static bool vfs_gpfs_fsp_is_offline(struct vfs_handle_struct *handle,
> struct files_struct *fsp)
> {
> - return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
> + struct gpfs_fsp_extension *ext;
> +
> + ext = VFS_FETCH_FSP_EXTENSION(handle, fsp);
> + if (ext == NULL) {
> + /*
> + * Something bad happened, always ask.
> + */
> + return vfs_gpfs_is_offline(handle, fsp->fsp_name,
> + &fsp->fsp_name->st);
> + }
> +
> + if (ext->offline) {
> + /*
> + * As long as it's offline, ask.
> + */
> + ext->offline = vfs_gpfs_is_offline(handle, fsp->fsp_name,
> + &fsp->fsp_name->st);
> + }
> +
> + return ext->offline;
> }
>
> static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
> @@ -2207,6 +2230,8 @@ static int vfs_gpfs_open(struct vfs_handle_struct *handle,
> int flags, mode_t mode)
> {
> struct gpfs_config_data *config;
> + int ret;
> + struct gpfs_fsp_extension *ext;
>
> SMB_VFS_HANDLE_GET_DATA(handle, config,
> struct gpfs_config_data,
> @@ -2223,7 +2248,24 @@ static int vfs_gpfs_open(struct vfs_handle_struct *handle,
> if (config->syncio) {
> flags |= O_SYNC;
> }
> - return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
> +
> + ext = VFS_ADD_FSP_EXTENSION(handle, fsp, struct gpfs_fsp_extension,
> + NULL);
> + if (ext == NULL) {
> + errno = ENOMEM;
> + return -1;
> + }
> +
> + /*
> + * Assume the file is offline until gpfs tells us it's online.
> + */
> + *ext = (struct gpfs_fsp_extension) { .offline = true };
> +
> + ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
> + if (ret == -1) {
> + VFS_REMOVE_FSP_EXTENSION(handle, fsp);
> + }
> + return ret;
> }
>
> static ssize_t vfs_gpfs_pread(vfs_handle_struct *handle, files_struct *fsp,
> --
> 1.9.1
>
More information about the samba-technical
mailing list