Yes, we are testing in WSL environment. On removing the mount mark, git clone succeeds. We are using the releases from: https://github.com/microsoft/WSL2-Linux-Kernel/releases Did u get to try git clone operation on 9p mount on your setup ? May I know the kernel version ? Can you share the commands of how you created a 9p mount on your test box ? Please find the code for rename(attached), execute and share the result in 9p mount of ur setup. I have tested the fanotify example. It is working in WSL environment. Infact even, in the example code, I have marked only with FAN_CLOSE_WRITE mask. This event handler is recognizing the event and printing it. Thank you, Krishna Vivek -----Original Message----- From: Amir Goldstein <amir73il@xxxxxxxxx> Sent: Tuesday, September 24, 2024 2:27 PM To: Krishna Vivek Vitta <kvitta@xxxxxxxxxxxxx> Cc: linux-fsdevel@xxxxxxxxxxxxxxx; jack@xxxxxxx Subject: Re: [EXTERNAL] Re: Git clone fails in p9 file system marked with FANOTIFY On Tue, Sep 24, 2024 at 7:25 AM Krishna Vivek Vitta <kvitta@xxxxxxxxxxxxx> wrote: > > Hi Amir > > Thanks for the reply. > > We have another image with kernel version: 6.6.36.3. git clone operation fails there as well. Do we need to still try with 5.15.154 kernel version ? No need. > > Currently, we are marking the mount points with mask(FAN_CLOSE_WRITE) to handle only close_write events. Do we need to add any other flag in mask and check ? No need. > > Following is the mount entry in /proc/mounts file: > C:\134 /mnt/c 9p > rw,noatime,aname=drvfs;path=C:\;uid=0;gid=0;symlinkroot=/mnt/,cache=5, > access=client,msize=65536,trans=fd,rfd=4,wfd=4 0 0 I don't know this symlinkroot feature. It looks like a WSL2 feature (?) and my guess is that the failure might be related. Not sure how fanotify mount mark affects this, maybe because the close_write events open the file for reporting the event, but maybe you should try to ask your question also the WSL2 kernel maintainers. I have tried to reproduce your test case on the 9p mount on my test box: v_tmp on /vtmp type 9p (rw,relatime,access=client,msize=262144,trans=virtio) with fanotify examples program: https://manpages.debian.org/unstable/manpages/fanotify.7.en.html#Example_program:_fanotify_example.c and could not reproduce the issue with plain: echo 123 > x && mv x y && cat y > > Attached is the strace for failed git clone operation(line: 419, 420). All the failures are ENOENT, which is why I suspect maybe related to the symlinkroot thing. > Even I wrote a small program to invoke rename, followed with open. > The open fails immediately and succeeds after 3-4 iterations. > This exercise was performed on p9 file system marked with fanotify. Please share your reproducer program. The difference could be in the details. Can you test in a 9p mount without those WSL options? Can you test on upstream or LTS kernel? Can you test with the fanotify example? > > Am not reporting this as regression. We havent checked this behavior before. > Ok. patience, we will try to get to the bottom of this. Thanks, Amir.
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <errno.h> int main() { const char *filename = "config.lock"; const char *new_filename = "config"; const char *content = "Hello, this is a test with file rename operation.\n"; char buffer[100]; int fd; ssize_t bytes_read; int counter=0; // Delete the file if it already exists if (access(new_filename, F_OK) != -1) { if (remove(new_filename) != 0) { perror("Failed to delete existing file"); //return EXIT_FAILURE; } } // Create a new file and write to it fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd == -1) { perror("Failed to create file"); return EXIT_FAILURE; } if (write(fd, content, strlen(content)) == -1) { perror("Failed to write to file"); close(fd); return EXIT_FAILURE; } close(fd); // Rename the file if (rename(filename, new_filename) != 0) { perror("Failed to rename file"); return EXIT_FAILURE; } // Open the renamed file and read the content fd=-1; /* while(fd==-1) { fd = open(new_filename, O_RDONLY); counter++; } printf("File appeared in %d iterations\n", counter); */ fd = open(new_filename, O_RDONLY); if (fd == -1) { perror("Failed to open renamed file"); return EXIT_FAILURE; } bytes_read = read(fd, buffer, sizeof(buffer) - 1); if (bytes_read == -1) { perror("Failed to read from file"); close(fd); return EXIT_FAILURE; } buffer[bytes_read] = '\0'; // Null-terminate the buffer close(fd); // Print the content printf("Content of %s:\n%s", new_filename, buffer); return EXIT_SUCCESS; }