Skip to contentSkip to conversation

unfs3: fix symlink time setting issue

PATCH In review Chen Qi 2 participants 3 messages Apr 25, 2023 – Apr 27, 2023

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH 1/1 unfs3: fix symlink time setting issue

Add back the dropped 0001-attr-fix-utime-for-symlink.patch to fix symlink time setting issue on NFS.

The problem could be reproduced by runing the following command on nfs booted qemu:

ln -s dest src && touch -h src

Apart from the rpm operations mentioned in the original patch, 'docker pull' also fails with a 'stale file' error. The common pattern here is extracting files from a bundle and setting times for them.

---
 .../0001-attr-fix-utime-for-symlink.patch     | 88 +++++++++++++++++++
 meta/recipes-devtools/unfs3/unfs3_git.bb      |  1 +
 2 files changed, 89 insertions(+)
 create mode 100644 meta/recipes-devtools/unfs3/unfs3/0001-attr-fix-utime-for-symlink.patch
meta/recipes-devtools/unfs3/unfs3/0001-attr-fix-utime-for-symlink.patch new file +88 -0
new file mode 100644
index 0000000000..a0f3740d6a
@@ -0,0 +1,88 @@
+From 7e789895919d57d573ebb8faa147d1286104cd01 Mon Sep 17 00:00:00 2001
+From: Rui Wang <[email protected]>
+Date: Mon, 24 Apr 2023 02:57:57 -0700
+Subject: [PATCH] attr: fix utime for symlink
+
+unfs3 has an old defect that it can not change the timestamps of a
+symlink file because it only uses utime(), which will follow the
+symlink. This will not cause an error if the symlink points to an
+existent file. But under some special situation, such as installing
+a rpm package, rpm tool will create the symlink first and try to
+modify the timestamps of it, when the target file is non-existent.
+This will cause an ESTALE error. Making rpm tool ignore this error
+is a solution, but not the best one. An acceptable approach is
+Making unfs3 support lutimes(), which can modify the symlink file
+itself. Considering not every system support this function, so a
+function checking is necessary.
+
+Upstream-Status: Submitted [https://github.com/unfs3/unfs3/pull/35]
+
+Signed-off-by: Chen Qi <[email protected]>
+---
+ attr.c         | 15 +++++++++++----
+ backend_unix.h |  2 ++
+ configure.ac   |  1 +
+ 3 files changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/attr.c b/attr.c
+index 0ce9375..930ce6e 100644
+--- a/attr.c
++++ b/attr.c
+@@ -285,7 +285,7 @@ post_op_attr get_post_cached(struct svc_req * req)
+ static nfsstat3 set_time(const char *path, backend_statstruct buf, sattr3 new)
+ {
+     time_t new_atime, new_mtime;
+-    struct utimbuf utim;
++    struct timeval stamps[2];
+     int res;
+ 
+     /* set atime and mtime */
+@@ -307,10 +307,17 @@ static nfsstat3 set_time(const char *path, backend_statstruct buf, sattr3 new)
+ 	else			       /* DONT_CHANGE */
+ 	    new_mtime = buf.st_mtime;
+ 
+-	utim.actime = new_atime;
+-	utim.modtime = new_mtime;
++	stamps[0].tv_sec = new_atime;
++	stamps[0].tv_usec = 0;
++	stamps[1].tv_sec = new_mtime;
++	stamps[1].tv_usec = 0;
++
++#if HAVE_LUTIMES
++	res = backend_lutimes(path, stamps);
++#else
++	res = backend_utimes(path, stamps);
++#endif
+ 
+-	res = backend_utime(path, &utim);
+ 	if (res == -1)
+ 	    return setattr_err();
+     }
+diff --git a/backend_unix.h b/backend_unix.h
+index 4db72ae..9cce9ab 100644
+--- a/backend_unix.h
++++ b/backend_unix.h
+@@ -61,6 +61,8 @@
+ #define backend_symlink symlink
+ #define backend_truncate truncate
+ #define backend_utime utime
++#define backend_utimes utimes
++#define backend_lutimes lutimes
+ #define backend_statstruct struct stat
+ #define backend_dirstream DIR
+ #define backend_statvfsstruct struct statvfs
+diff --git a/configure.ac b/configure.ac
+index d46c905..c21afe3 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -32,6 +32,7 @@ AC_CHECK_FUNCS(setresuid setresgid)
+ AC_CHECK_FUNCS(vsyslog)
+ AC_CHECK_FUNCS(lchown)
+ AC_CHECK_FUNCS(setgroups)
++AC_CHECK_FUNCS(lutimes)
+ UNFS3_COMPILE_WARNINGS
+ 
+ PKG_CHECK_MODULES([TIRPC], [libtirpc])
+-- 
+2.40.0
+
meta/recipes-devtools/unfs3/unfs3_git.bb +1 -0
index 9913a503e8..c5b7898b3c 100644
@@ -17,6 +17,7 @@ SRC_URI = "git://github.com/unfs3/unfs3.git;protocol=https;branch=master \
            file://0001-Alias-off64_t-to-off_t-on-linux-if-not-defined.patch \
            file://0001-locate.c-Include-attr.h.patch \
            file://0001-fix-building-on-macOS.patch \
+           file://0001-attr-fix-utime-for-symlink.patch \
            "
 SRCREV = "c8f2d2cd4529955419bad0e163f88d47ff176b8d"
 UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>\d+(\.\d+)+)"
Signature · 1 line
2.40.0
#1 lore raw

Hello Chen,

On Mon, 24 Apr 2023 22:05:17 -0700
"Chen Qi via lists.openembedded.org" <[email protected]> wrote:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As you can see your sender address has been mangled, and as a result the patch is rejected by the the openembedded git server. This is not your fault, but we need you to modify your git configuration to prevent this from happening in the future. Have a look at the wiki for more info and how to solve that:

https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded#Fixing_your_From_identity

I'm taking your patch for testing on the autobuilders, fixing it manually so you don't need to resend your patch this time.

Best regards,
Luca

Signature · 3 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#2 lore raw

Thanks Luca.

I found my .gitconfig setting is:
from = Chen Qi <[email protected]>

I've now changed it to:
From = [email protected]

Hope this would solve the problem.

Regards,
Qi

-----Original Message-----
From: Luca Ceresoli <[email protected]>
Sent: Wednesday, April 26, 2023 5:30 PM
To: Chen Qi via lists.openembedded.org <[email protected]>
Cc: Chen, Qi <[email protected]>; [email protected]
Subject: Re: [OE-core][PATCH] unfs3: fix symlink time setting issue

Hello Chen,

On Mon, 24 Apr 2023 22:05:17 -0700
"Chen Qi via lists.openembedded.org" <[email protected]> wrote:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As you can see your sender address has been mangled, and as a result the patch is rejected by the the openembedded git server. This is not your fault, but we need you to modify your git configuration to prevent this from happening in the future. Have a look at the wiki for more info and how to solve that:

https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded#Fixing_your_From_identity

I'm taking your patch for testing on the autobuilders, fixing it manually so you don't need to resend your patch this time.

Best regards,
Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com