* [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink
@ 2023-06-07 8:47 David Howells
2023-06-07 8:56 ` David Howells
0 siblings, 1 reply; 5+ messages in thread
From: David Howells @ 2023-06-07 8:47 UTC (permalink / raw)
To: torvalds
Cc: dhowells, Jeffrey Altman, Marc Dionne, linux-afs, linux-fsdevel,
linux-kernel
kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when
creating a file, dir or symlink because the mtime recorded in the
afs_operation struct gets passed to the server by the marshalling routines,
but the afs_mkdir(), afs_create() and afs_symlink() functions don't set it.
This gets masked if a file or directory is subsequently modified.
Fix this by filling in op->mtime before calling the create op.
Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/dir.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 4dd97afa536c..5219182e52e1 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
op->dentry = dentry;
op->create.mode = S_IFDIR | mode;
op->create.reason = afs_edit_dir_for_mkdir;
+ op->mtime = current_time(dir);
op->ops = &afs_mkdir_operation;
return afs_do_sync_operation(op);
}
@@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
op->dentry = dentry;
op->create.mode = S_IFREG | mode;
op->create.reason = afs_edit_dir_for_create;
+ op->mtime = current_time(dir);
op->ops = &afs_create_operation;
return afs_do_sync_operation(op);
@@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
op->ops = &afs_symlink_operation;
op->create.reason = afs_edit_dir_for_symlink;
op->create.symlink = content;
+ op->mtime = current_time(dir);
return afs_do_sync_operation(op);
error:
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink
2023-06-07 8:47 [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink David Howells
@ 2023-06-07 8:56 ` David Howells
0 siblings, 0 replies; 5+ messages in thread
From: David Howells @ 2023-06-07 8:56 UTC (permalink / raw)
To: torvalds
Cc: dhowells, Jeffrey Altman, Marc Dionne, linux-afs, linux-fsdevel,
linux-kernel
Hi Linus,
Sorry, I forgot to say in the patch email, but could you apply this please?
Thanks,
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink
@ 2023-05-31 22:50 David Howells
2023-06-01 0:15 ` Jeffrey E Altman
2023-06-01 13:25 ` Marc Dionne
0 siblings, 2 replies; 5+ messages in thread
From: David Howells @ 2023-05-31 22:50 UTC (permalink / raw)
To: Marc Dionne; +Cc: dhowells, linux-afs, linux-fsdevel, linux-kernel
kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when
creating a file, dir or symlink because commit 52af7105eceb caused the
mtime recorded in the afs_operation struct to be passed to the server, but
didn't modify the afs_mkdir(), afs_create() and afs_symlink() functions to
set it first.
Those functions were written with the assumption that the mtime would be
obtained from the server - but that fell foul of malsynchronised clocks, so
it was decided that the mtime should be set from the client instead.
Fix this by filling in op->mtime before calling the create op.
Fixes: 52af7105eceb ("afs: Set mtime from the client for yfs create operations")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/dir.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 4dd97afa536c..5219182e52e1 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
op->dentry = dentry;
op->create.mode = S_IFDIR | mode;
op->create.reason = afs_edit_dir_for_mkdir;
+ op->mtime = current_time(dir);
op->ops = &afs_mkdir_operation;
return afs_do_sync_operation(op);
}
@@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
op->dentry = dentry;
op->create.mode = S_IFREG | mode;
op->create.reason = afs_edit_dir_for_create;
+ op->mtime = current_time(dir);
op->ops = &afs_create_operation;
return afs_do_sync_operation(op);
@@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
op->ops = &afs_symlink_operation;
op->create.reason = afs_edit_dir_for_symlink;
op->create.symlink = content;
+ op->mtime = current_time(dir);
return afs_do_sync_operation(op);
error:
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink
2023-05-31 22:50 David Howells
@ 2023-06-01 0:15 ` Jeffrey E Altman
2023-06-01 13:25 ` Marc Dionne
1 sibling, 0 replies; 5+ messages in thread
From: Jeffrey E Altman @ 2023-06-01 0:15 UTC (permalink / raw)
To: David Howells, Marc Dionne; +Cc: linux-afs, linux-fsdevel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2126 bytes --]
On 5/31/2023 6:50 PM, David Howells wrote:
>
> kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when
> creating a file, dir or symlink because commit 52af7105eceb caused the
> mtime recorded in the afs_operation struct to be passed to the server, but
> didn't modify the afs_mkdir(), afs_create() and afs_symlink() functions to
> set it first.
>
> Those functions were written with the assumption that the mtime would be
> obtained from the server - but that fell foul of malsynchronised clocks, so
> it was decided that the mtime should be set from the client instead.
>
> Fix this by filling in op->mtime before calling the create op.
>
> Fixes: 52af7105eceb ("afs: Set mtime from the client for yfs create operations")
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: linux-afs@lists.infradead.org
> cc: linux-fsdevel@vger.kernel.org
> ---
> fs/afs/dir.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 4dd97afa536c..5219182e52e1 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> op->dentry = dentry;
> op->create.mode = S_IFDIR | mode;
> op->create.reason = afs_edit_dir_for_mkdir;
> + op->mtime = current_time(dir);
> op->ops = &afs_mkdir_operation;
> return afs_do_sync_operation(op);
> }
> @@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
> op->dentry = dentry;
> op->create.mode = S_IFREG | mode;
> op->create.reason = afs_edit_dir_for_create;
> + op->mtime = current_time(dir);
> op->ops = &afs_create_operation;
> return afs_do_sync_operation(op);
>
> @@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> op->ops = &afs_symlink_operation;
> op->create.reason = afs_edit_dir_for_symlink;
> op->create.symlink = content;
> + op->mtime = current_time(dir);
> return afs_do_sync_operation(op);
>
> error:
>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4039 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink
2023-05-31 22:50 David Howells
2023-06-01 0:15 ` Jeffrey E Altman
@ 2023-06-01 13:25 ` Marc Dionne
1 sibling, 0 replies; 5+ messages in thread
From: Marc Dionne @ 2023-06-01 13:25 UTC (permalink / raw)
To: David Howells; +Cc: linux-afs, linux-fsdevel, linux-kernel
On Wed, May 31, 2023 at 7:50 PM David Howells <dhowells@redhat.com> wrote:
>
>
> kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when
> creating a file, dir or symlink because commit 52af7105eceb caused the
> mtime recorded in the afs_operation struct to be passed to the server, but
> didn't modify the afs_mkdir(), afs_create() and afs_symlink() functions to
> set it first.
>
> Those functions were written with the assumption that the mtime would be
> obtained from the server - but that fell foul of malsynchronised clocks, so
> it was decided that the mtime should be set from the client instead.
>
> Fix this by filling in op->mtime before calling the create op.
>
> Fixes: 52af7105eceb ("afs: Set mtime from the client for yfs create operations")
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: linux-afs@lists.infradead.org
> cc: linux-fsdevel@vger.kernel.org
> ---
> fs/afs/dir.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 4dd97afa536c..5219182e52e1 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> op->dentry = dentry;
> op->create.mode = S_IFDIR | mode;
> op->create.reason = afs_edit_dir_for_mkdir;
> + op->mtime = current_time(dir);
> op->ops = &afs_mkdir_operation;
> return afs_do_sync_operation(op);
> }
> @@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
> op->dentry = dentry;
> op->create.mode = S_IFREG | mode;
> op->create.reason = afs_edit_dir_for_create;
> + op->mtime = current_time(dir);
> op->ops = &afs_create_operation;
> return afs_do_sync_operation(op);
>
> @@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> op->ops = &afs_symlink_operation;
> op->create.reason = afs_edit_dir_for_symlink;
> op->create.symlink = content;
> + op->mtime = current_time(dir);
> return afs_do_sync_operation(op);
>
> error:
The fix looks good, but as we discussed privately, the issue that this
fixes predates commit 52af7105eceb. That commit only touched the yfs
client code and made it rely on the op mtime rather than letting the
server set the time. This made it inherit the issue that was already
present for the non yfs client code.
Marc
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-07 8:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 8:47 [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink David Howells
2023-06-07 8:56 ` David Howells
-- strict thread matches above, loose matches on Subject: below --
2023-05-31 22:50 David Howells
2023-06-01 0:15 ` Jeffrey E Altman
2023-06-01 13:25 ` Marc Dionne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®