2018-01-29 02:58:27

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 1/2] NFS: Remove a redundant call to unmap_mapping_range()

We don't need to call unmap_mapping_range() prior to calling
nfs_sync_mapping().

Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/inode.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index deeb7d1097d0..49fba9ea5872 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1170,7 +1170,6 @@ static int nfs_invalidate_mapping(struct inode *inode, struct address_space *map

if (mapping->nrpages != 0) {
if (S_ISREG(inode->i_mode)) {
- unmap_mapping_range(mapping, 0, 0, 0);
ret = nfs_sync_mapping(mapping);
if (ret < 0)
return ret;
--
2.14.3



2018-01-29 02:58:28

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 2/2] NFS: Fix a race between mmap() and O_DIRECT

When locking the file in order to do O_DIRECT on it, we must unmap
any mmapped ranges on the pagecache so that we can flush out the
dirty data.

Signed-off-by: Trond Myklebust <[email protected]>
Cc: [email protected] # v4.8+
---
fs/nfs/io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/io.c b/fs/nfs/io.c
index 20fef85d2bb1..9034b4926909 100644
--- a/fs/nfs/io.c
+++ b/fs/nfs/io.c
@@ -99,7 +99,7 @@ static void nfs_block_buffered(struct nfs_inode *nfsi, struct inode *inode)
{
if (!test_bit(NFS_INO_ODIRECT, &nfsi->flags)) {
set_bit(NFS_INO_ODIRECT, &nfsi->flags);
- nfs_wb_all(inode);
+ nfs_sync_mapping(inode->i_mapping);
}
}

--
2.14.3


2018-02-07 06:42:54

by NeilBrown

[permalink] [raw]
Subject: Re: [PATCH 1/2] NFS: Remove a redundant call to unmap_mapping_range()

On Sun, Jan 28 2018, Trond Myklebust wrote:

> We don't need to call unmap_mapping_range() prior to calling
> nfs_sync_mapping().

Don't we?
Doesn't that allow a process which mapped the page to dirty it
immediately after nfs_sync_mapping(), without the page being
reloaded from the server first?
Doesn't seem right..

Thanks,
NeilBrown


>
> Signed-off-by: Trond Myklebust <[email protected]>
> ---
> fs/nfs/inode.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index deeb7d1097d0..49fba9ea5872 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -1170,7 +1170,6 @@ static int nfs_invalidate_mapping(struct inode *inode, struct address_space *map
>
> if (mapping->nrpages != 0) {
> if (S_ISREG(inode->i_mode)) {
> - unmap_mapping_range(mapping, 0, 0, 0);
> ret = nfs_sync_mapping(mapping);
> if (ret < 0)
> return ret;
> --
> 2.14.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html


Attachments:
signature.asc (832.00 B)

2018-02-07 11:46:53

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 1/2] NFS: Remove a redundant call to unmap_mapping_range()

On Wed, 2018-02-07 at 17:42 +1100, NeilBrown wrote:
> On Sun, Jan 28 2018, Trond Myklebust wrote:
>
> > We don't need to call unmap_mapping_range() prior to calling
> > nfs_sync_mapping().
>
> Don't we?

See line 2 of nfs_sync_mapping(). ☺

> Doesn't that allow a process which mapped the page to dirty it
> immediately after nfs_sync_mapping(), without the page being
> reloaded from the server first?
> Doesn't seem right..
>
> Thanks,
> NeilBrown
>
>
> >
> > Signed-off-by: Trond Myklebust <[email protected]>
> > ---
> > fs/nfs/inode.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> > index deeb7d1097d0..49fba9ea5872 100644
> > --- a/fs/nfs/inode.c
> > +++ b/fs/nfs/inode.c
> > @@ -1170,7 +1170,6 @@ static int nfs_invalidate_mapping(struct
> > inode *inode, struct address_space *map
> >
> > if (mapping->nrpages != 0) {
> > if (S_ISREG(inode->i_mode)) {
> > - unmap_mapping_range(mapping, 0, 0, 0);
> > ret = nfs_sync_mapping(mapping);
> > if (ret < 0)
> > return ret;
> > --
> > 2.14.3
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-
> > nfs" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]


Attachments:
signature.asc (833.00 B)
This is a digitally signed message part

2018-02-07 21:20:52

by NeilBrown

[permalink] [raw]
Subject: Re: [PATCH 1/2] NFS: Remove a redundant call to unmap_mapping_range()

On Wed, Feb 07 2018, Trond Myklebust wrote:

> On Wed, 2018-02-07 at 17:42 +1100, NeilBrown wrote:
>> On Sun, Jan 28 2018, Trond Myklebust wrote:
>>
>> > We don't need to call unmap_mapping_range() prior to calling
>> > nfs_sync_mapping().
>>
>> Don't we?
>
> See line 2 of nfs_sync_mapping(). ☺

Ahhh. Makes perfect sense now - thanks

NeilBrown


>
>> Doesn't that allow a process which mapped the page to dirty it
>> immediately after nfs_sync_mapping(), without the page being
>> reloaded from the server first?
>> Doesn't seem right..
>>
>> Thanks,
>> NeilBrown
>>
>>
>> >
>> > Signed-off-by: Trond Myklebust <[email protected]>
>> > ---
>> > fs/nfs/inode.c | 1 -
>> > 1 file changed, 1 deletion(-)
>> >
>> > diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
>> > index deeb7d1097d0..49fba9ea5872 100644
>> > --- a/fs/nfs/inode.c
>> > +++ b/fs/nfs/inode.c
>> > @@ -1170,7 +1170,6 @@ static int nfs_invalidate_mapping(struct
>> > inode *inode, struct address_space *map
>> >
>> > if (mapping->nrpages != 0) {
>> > if (S_ISREG(inode->i_mode)) {
>> > - unmap_mapping_range(mapping, 0, 0, 0);
>> > ret = nfs_sync_mapping(mapping);
>> > if (ret < 0)
>> > return ret;
>> > --
>> > 2.14.3
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-
>> > nfs" in
>> > the body of a message to [email protected]
>> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> Trond Myklebust
> Linux NFS client maintainer, PrimaryData
> [email protected]


Attachments:
signature.asc (832.00 B)