tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PUFFS ADVLOCK is to greedy

Please consider the test case below, ran on a PUFFS/perfuse/glusterfs
mount. A look at the PUFFS operation trace shows that the kernel sends
ADVLOCK for f0, f1 and m when a lock is requested on m.

It only happens if f0 and f1 are open read-only. As I understand, a lock
requested on a file cause all files open read-only to be locked too.

I have not yet investigated what happens in libpuffs and in the kernel,
but the question is: does that make any sense? Is it somewhat a known

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include <sysexits.h>
#include <sys/param.h>

        int fd, i, fi;
        struct flock fl;
        char fpath[MAXPATHLEN + 1];

        for (i = 0; i < 2; i++) {
                (void)sprintf(fpath, "f%d", i);

                if (access(fpath, F_OK) == -1) {
                        if ((fi = open(fpath, O_CREAT, 0644)) == -1)
                                err(EX_OSERR, "open failed");
                        if (close(fi) != 0)
                                err(EX_OSERR, "close failed");

                if ((fi = open(fpath, O_RDONLY, 0644)) == -1)
                        err(EX_OSERR, "open failed");

        if ((fd = open("m", O_CREAT|O_WRONLY|O_APPEND, 0)) == -1)
                err(EX_OSERR, "open failed");

        fl.l_start = 0;
        fl.l_len = 0;
        fl.l_whence = SEEK_SET;
        fl.l_type = F_WRLCK;
        if (fcntl(fd, F_SETLKW, &fl) == -1)
                err(EX_OSERR, "fcntl failed");

        return 0;       

Emmanuel Dreyfus

Home | Main Index | Thread Index | Old Index