lkml.org 
[lkml]   [2003]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] fs/locks.c fcntl_setlease did not check if a file was opened for writing before granting a read lease
Jamie Lokier writes:
> Joseph D. Wagner wrote:
> > But I THINK this is how a patch would fix the problem, in theory.
>
> Sorry, it won't.
>
> > + if ((arg == F_RDLCK)
> > + && ((dentry->d_flags & O_WRONLY)
> > + || (dentry->d_flags & O_RDWR)
> > + || (dentry->d_flags & O_CREAT)
> > + || (dentry->d_flags & O_TRUNC)
> > + || (inode->i_flags & O_WRONLY)
> > + || (inode->i_flags & O_RDWR)
> > + || (inode->i_flags & O_CREAT)
> > + || (inode->i_flags & O_TRUNC)))
> > + goto out_unlock;
>
> dentry->d_flags is a combination of the S_ flags, not O_ flags.
> E.g. S_SYNC, S_NOATIME etc.
>
> inode->i_flags is a combination of the DCACHE_ flags.
> E.g. DCACHE_AUTOFS_PENDING, DCACHE_REFERENCED tc.

I think it is other way around. ->i_flags are combined from S_SYNC (see,
include/linux/fs.h:IS_IMMUTABLE(), for example), and ->d_flags are
combined from DCACHE_*, latter is explicitly stated in
include/linux/dcache.h

>
> To detect if anyone has the file open for writing, you'll a new count
> field which keeps track of writer references. Something like this:
>
> if ((arg == F_RDLCK)
> && ((atomic_read(&inode->i_writer_count) != 0)))
>
> You'll also need to modify all the places where that needs to be
> maintained.
>
> Btw, I'm not sure why the F_WRLCK case needs to check d_count and
> i_count. Isn't it enough to check d_count? Won't all opens reference
> the inode through a dentry?:
>
> > if ((arg == F_WRLCK)
> > && ((atomic_read(&dentry->d_count) > 1)
> > || (atomic_read(&inode->i_count) > 1)))
>
> -- Jamie

Nikita.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.060 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site