- From b3bf7fb93544ab93cba00ee70ef7bf76521b6f34 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 16 Apr 2025 10:41:02 +0200
- Subject: [PATCH 1/3] daemon: |handle_duplicatedata()| should use src+dst
- offsets
- |handle_duplicatedata()| should use src+dst offsets
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/fsctl.c | 31 ++++++++++++++++++++++++-------
- 1 file changed, 24 insertions(+), 7 deletions(-)
- diff --git a/daemon/fsctl.c b/daemon/fsctl.c
- index 91f0763..8f93ab3 100644
- --- a/daemon/fsctl.c
- +++ b/daemon/fsctl.c
- @@ -523,14 +523,28 @@ int handle_duplicatedata(void *daemon_context,
- }
- src_file_size = info.size;
- - if (args->bytecount > src_file_size)
- - bytecount = src_file_size;
- + if ((args->srcfileoffset+args->bytecount) > src_file_size)
- + bytecount = src_file_size-args->srcfileoffset;
- else
- bytecount = args->bytecount;
- #else
- bytecount = args->bytecount;
- #endif /* CLONE_PUNCH_HOLE_IF_CLONESIZE_BIGGER_THAN_SRCFILESIZE */
- + EASSERT(bytecount > 0);
- + if (bytecount <= 0) {
- + DPRINTF(DDLVL,
- + ("handle_duplicatedata("
- + "src_state->path.path='%s' "
- + "dst_state->path.path='%s'): "
- + "Negative bytecount %lld\n",
- + src_state->path.path,
- + dst_state->path.path,
- + bytecount));
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +
- status = nfs42_clone(session,
- src_file,
- dst_file,
- @@ -553,19 +567,22 @@ int handle_duplicatedata(void *daemon_context,
- }
- #ifdef CLONE_PUNCH_HOLE_IF_CLONESIZE_BIGGER_THAN_SRCFILESIZE
- - if (args->bytecount > src_file_size) {
- + if ((args->srcfileoffset+args->bytecount) > src_file_size) {
- DPRINTF(DDLVL,
- ("handle_duplicatedata(): "
- - "Clone range (%llu) bigger than source file size "
- - "(%llu), adding hole at the end of dest file.\n",
- + "Clone range (offset(=%lld)+bytecount(=%lld)=%lld) "
- + "bigger than source file size (%lld), "
- + "adding hole at the end of dest file.\n",
- + args->srcfileoffset,
- args->bytecount,
- + (args->srcfileoffset+args->bytecount),
- src_file_size));
- status = nfs42_deallocate(session,
- dst_file,
- &dst_stateid,
- - src_file_size,
- - (args->bytecount - src_file_size),
- + args->destfileoffset+src_file_size,
- + ((args->srcfileoffset+args->bytecount) - src_file_size),
- &info);
- if (status) {
- DPRINTF(DDLVL,
- --
- 2.45.1
- From 738235baba453fca88a3ae5a7d514f7645e53a26 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 16 Apr 2025 10:50:02 +0200
- Subject: [PATCH 2/3] daemon: |DPRINTF()| debug level for
- |handle_duplicatedata()| should be |2| except error code paths
- |DPRINTF()| debug level for |handle_duplicatedata()| should be |2|
- except error code paths.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/fsctl.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
- diff --git a/daemon/fsctl.c b/daemon/fsctl.c
- index 8f93ab3..595c7be 100644
- --- a/daemon/fsctl.c
- +++ b/daemon/fsctl.c
- @@ -29,7 +29,7 @@
- #define QARLVL 2 /* dprintf level for "query allocated ranges" logging */
- #define SZDLVL 2 /* dprintf level for "set zero data" logging */
- -#define DDLVL 0 /* dprintf level for "duplicate data" logging */
- +#define DDLVL 2 /* dprintf level for "duplicate data" logging */
- static int parse_queryallocatedranges(unsigned char *buffer,
- uint32_t length, nfs41_upcall *upcall)
- @@ -533,7 +533,7 @@ int handle_duplicatedata(void *daemon_context,
- EASSERT(bytecount > 0);
- if (bytecount <= 0) {
- - DPRINTF(DDLVL,
- + DPRINTF(0/*DDLVL*/,
- ("handle_duplicatedata("
- "src_state->path.path='%s' "
- "dst_state->path.path='%s'): "
- @@ -555,7 +555,7 @@ int handle_duplicatedata(void *daemon_context,
- bytecount,
- &info);
- if (status) {
- - DPRINTF(DDLVL,
- + DPRINTF(0/*DDLVL*/,
- ("handle_duplicatedata("
- "src_state->path.path='%s' "
- "dst_state->path.path='%s'): "
- @@ -585,7 +585,7 @@ int handle_duplicatedata(void *daemon_context,
- ((args->srcfileoffset+args->bytecount) - src_file_size),
- &info);
- if (status) {
- - DPRINTF(DDLVL,
- + DPRINTF(0/*DDLVL*/,
- ("handle_duplicatedata("
- "src_state->path.path='%s' "
- "dst_state->path.path='%s'): "
- @@ -609,7 +609,7 @@ int handle_duplicatedata(void *daemon_context,
- args->ctime));
- out:
- - DPRINTF(0,
- + DPRINTF(DDLVL,
- ("<-- handle_duplicatedata(), status=0x%lx\n",
- status));
- --
- 2.45.1
- From f3741916db9db5c69fac5de8812d2d6a73f2cbac Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 16 Apr 2025 11:31:15 +0200
- Subject: [PATCH 3/3] daemon: Add enable/disable booleans for NFSv4.2 OPs to
- |nfs41_root|
- Add enable/disable booleans for NFSv4.2 OPs (READ_PLUS, SEEK, ALLOCATE,
- DEALLOCATE, CLONE) to |nfs41_root|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/fsctl.c | 25 +++++++++++++++++--------
- daemon/namespace.c | 14 +++++++++++---
- daemon/nfs41.h | 4 ++++
- daemon/open.c | 2 +-
- 4 files changed, 33 insertions(+), 12 deletions(-)
- diff --git a/daemon/fsctl.c b/daemon/fsctl.c
- index 595c7be..1b50fc3 100644
- --- a/daemon/fsctl.c
- +++ b/daemon/fsctl.c
- @@ -65,6 +65,7 @@ int query_sparsefile_datasections(nfs41_open_state *state,
- size_t *restrict res_num_records)
- {
- int status = NO_ERROR;
- + nfs41_session *session = state->session;
- uint64_t next_offset;
- uint64_t data_size;
- int data_seek_status;
- @@ -82,8 +83,8 @@ int query_sparsefile_datasections(nfs41_open_state *state,
- ("--> query_sparsefile_datasections(state->path.path='%s')\n",
- state->path.path));
- - /* NFS SEEK requires NFSv4.2 */
- - if (state->session->client->root->nfsminorvers < 2) {
- + /* NFS SEEK supported ? */
- + if (session->client->root->supports_nfs42_seek == false) {
- status = ERROR_NOT_SUPPORTED;
- goto out;
- }
- @@ -94,7 +95,7 @@ int query_sparsefile_datasections(nfs41_open_state *state,
- *res_num_records = 0;
- for (i=0 ; ; i++) {
- - data_seek_status = nfs42_seek(state->session,
- + data_seek_status = nfs42_seek(session,
- &state->file,
- &stateid,
- next_offset,
- @@ -143,7 +144,7 @@ int query_sparsefile_datasections(nfs41_open_state *state,
- next_offset = data_seek_sr_offset;
- - hole_seek_status = nfs42_seek(state->session,
- + hole_seek_status = nfs42_seek(session,
- &state->file,
- &stateid,
- next_offset,
- @@ -368,8 +369,8 @@ int handle_setzerodata(void *daemon_context,
- offset_end,
- len));
- - /* NFS DEALLOCATE requires NFSv4.2 */
- - if (state->session->client->root->nfsminorvers < 2) {
- + /* NFS DEALLOCATE supported ? */
- + if (session->client->root->supports_nfs42_deallocate == false) {
- status = ERROR_NOT_SUPPORTED;
- goto out;
- }
- @@ -501,12 +502,20 @@ int handle_duplicatedata(void *daemon_context,
- dst_state->path.path,
- src_state->path.path));
- - /* NFS CLONE requires NFSv4.2 */
- - if (dst_state->session->client->root->nfsminorvers < 2) {
- + /* NFS CLONE supported ? */
- + if (session->client->root->supports_nfs42_clone == false) {
- status = ERROR_NOT_SUPPORTED;
- goto out;
- }
- +#ifdef CLONE_PUNCH_HOLE_IF_CLONESIZE_BIGGER_THAN_SRCFILESIZE
- + /* NFS DEALLOCATE supported ? */
- + if (session->client->root->supports_nfs42_deallocate == false) {
- + status = ERROR_NOT_SUPPORTED;
- + goto out;
- + }
- +#endif /* CLONE_PUNCH_HOLE_IF_CLONESIZE_BIGGER_THAN_SRCFILESIZE */
- +
- nfs41_open_stateid_arg(src_state, &src_stateid);
- nfs41_open_stateid_arg(dst_state, &dst_stateid);
- diff --git a/daemon/namespace.c b/daemon/namespace.c
- index b5363eb..4511b52 100644
- --- a/daemon/namespace.c
- +++ b/daemon/namespace.c
- @@ -69,7 +69,11 @@ int nfs41_root_create(
- * nfs41_root_mount_addrs() will enable NFSv4.2 features (like
- * |OP_READ_PLUS|) after NFSv4.x minor version autonegitiation
- */
- - root->supports_nfs42_read_plus = false;
- + root->supports_nfs42_read_plus = false;
- + root->supports_nfs42_seek = false;
- + root->supports_nfs42_allocate = false;
- + root->supports_nfs42_deallocate = false;
- + root->supports_nfs42_clone = false;
- if (nfsvers == NFS_VERSION_AUTONEGOTIATION) {
- /*
- * Use auto negotiation, |nfs41_root_mount_addrs()| will
- @@ -445,8 +449,12 @@ retry_nfs41_exchange_id:
- /* Enable NFS features after NFSv4.x minor version negotiation */
- if (root->nfsminorvers >= 2) {
- - DPRINTF(0, ("nfs41_root_mount_addrs: Enabling OP_READ_PLUS\n"));
- - root->supports_nfs42_read_plus = true;
- + DPRINTF(0, ("nfs41_root_mount_addrs: Enabling NFSv4.2 OPs\n"));
- + root->supports_nfs42_read_plus = true;
- + root->supports_nfs42_seek = true;
- + root->supports_nfs42_allocate = true;
- + root->supports_nfs42_deallocate = true;
- + root->supports_nfs42_clone = true;
- }
- /* attempt to match existing clients by the exchangeid response */
- diff --git a/daemon/nfs41.h b/daemon/nfs41.h
- index 9c2bdab..ef23599 100644
- --- a/daemon/nfs41.h
- +++ b/daemon/nfs41.h
- @@ -304,6 +304,10 @@ typedef struct __nfs41_root {
- struct list_entry clients;
- bool use_nfspubfh;
- bool supports_nfs42_read_plus;
- + bool supports_nfs42_seek;
- + bool supports_nfs42_allocate;
- + bool supports_nfs42_deallocate;
- + bool supports_nfs42_clone;
- DWORD nfsminorvers;
- uint32_t wsize;
- uint32_t rsize;
- diff --git a/daemon/open.c b/daemon/open.c
- index d2629c0..1996e98 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -1204,7 +1204,7 @@ create_chgrp_out:
- #ifdef DEBUG_OPEN_SPARSE_FILES
- if ((status == 0) &&
- (info.type == NF4REG) &&
- - (state->session->client->root->nfsminorvers >= 2)) {
- + (state->session->client->root->supports_nfs42_seek)) {
- //debug_list_sparsefile_holes(state);
- debug_list_sparsefile_datasections(state);
- }
- --
- 2.45.1
msnfs41client: Patch for |handle_duplicatedata()| should use src+dst offsets+misc, 2025-04-16
Posted by Anonymous on Wed 16th Apr 2025 11:00
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.