Skip to contentSkip to conversation

Why is NFS using a_ops->freepage?

DISCUSSION Jan Kara 2 participants 3 messages Oct 5, 2017

Subsystems (3)
lore
Share & tools
lore

Jan Kara

author
#0 lore raw

Hello,

I'm doing some work in page cache handling and I have noticed that NFS is the only user of mapping->a_ops->freepage callback. From a quick look I don't see why isn't NFS using ->releasepage / ->invalidatepage callback as all other filesystems do? I agree you would have to set PagePrivate bit for those to get called for the directory mapping however that would seem like a cleaner thing to do anyway - in fact you do have private data in the page. Just they are not pointed to by page->private but instead are stored as page data... Am I missing something?

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#1 lore raw

SGkgSmFuLA0KDQpPbiBUaHUsIDIwMTctMTAtMDUgYXQgMTA6MzYgKzAyMDAsIEphbiBLYXJhIHdy b3RlOg0KPiBIZWxsbywNCj4gDQo+IEknbSBkb2luZyBzb21lIHdvcmsgaW4gcGFnZSBjYWNoZSBo YW5kbGluZyBhbmQgSSBoYXZlIG5vdGljZWQgdGhhdA0KPiBORlMgaXMNCj4gdGhlIG9ubHkgdXNl ciBvZiBtYXBwaW5nLT5hX29wcy0+ZnJlZXBhZ2UgY2FsbGJhY2suIEZyb20gYSBxdWljayBsb29r DQo+IEkNCj4gZG9uJ3Qgc2VlIHdoeSBpc24ndCBORlMgdXNpbmcgLT5yZWxlYXNlcGFnZSAvIC0+ aW52YWxpZGF0ZXBhZ2UNCj4gY2FsbGJhY2sgYXMNCj4gYWxsIG90aGVyIGZpbGVzeXN0ZW1zIGRv PyBJIGFncmVlIHlvdSB3b3VsZCBoYXZlIHRvIHNldCBQYWdlUHJpdmF0ZQ0KPiBiaXQgZm9yDQo+ IHRob3NlIHRvIGdldCBjYWxsZWQgZm9yIHRoZSBkaXJlY3RvcnkgbWFwcGluZyBob3dldmVyIHRo YXQgd291bGQgc2VlbQ0KPiBsaWtlDQo+IGEgY2xlYW5lciB0aGluZyB0byBkbyBhbnl3YXkgLSBp biBmYWN0IHlvdSBkbyBoYXZlIHByaXZhdGUgZGF0YSBpbg0KPiB0aGUNCj4gcGFnZS4gIEp1c3Qg dGhleSBhcmUgbm90IHBvaW50ZWQgdG8gYnkgcGFnZS0+cHJpdmF0ZSBidXQgaW5zdGVhZCBhcmUN Cj4gc3RvcmVkDQo+IGFzIHBhZ2UgZGF0YS4uLiBBbSBJIG1pc3Npbmcgc29tZXRoaW5nPw0KPiAN Cj4gCQkJCQkJCQlIb256YQ0KDQpJJ20gbm90IHVuZGVyc3RhbmRpbmcgeW91ciBwb2ludC4gZGVs ZXRlX2Zyb21fcGFnZV9jYWNoZSgpIGRvZXNuJ3QgY2FsbA0KcmVsZWFzZXBhZ2UgQUZBSUNTLg0K DQpUaGUgcG9pbnQgb2YgZnJlZXBhZ2UgaXMgdGhhdCBpdCBpcyBjYWxsZWQgYWZ0ZXIgdGhlIHBh Z2UgaGFzIGJlZW4NCnJlbW92ZWQgZnJvbSB0aGUgcGFnZSBjYWNoZS4NCg0KLS0gDQpUcm9uZCBN eWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRyb25k Lm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==

author
#2 lore raw
Quoted 21 lines · Trond Myklebust

Hi Jan,

Quoted 18 lines · Jan Kara

Hello,

I'm doing some work in page cache handling and I have noticed that NFS is
the only user of mapping->a_ops->freepage callback. From a quick look I
don't see why isn't NFS using ->releasepage / ->invalidatepage callback as
all other filesystems do? I agree you would have to set PagePrivate bit for
those to get called for the directory mapping however that would seem like
a cleaner thing to do anyway - in fact you do have private data in the
page. Just they are not pointed to by page->private but instead are stored
as page data... Am I missing something?

Quoted 4 lines
Quoted 1 line

Honza

I'm not understanding your point. delete_from_page_cache() doesn't call releasepage AFAICS.

No, but before getting to delete_from_page_cache() the filesystem is guaranteed to get either ->invalidatepage or ->releasepage callback called (if it defines them). And at that point the page is already locked and on its way to be destroyed. So my point was you could use these callbacks instead to achieve the same...

If you are afraid of races, I don't think those can happen for NFS. Page can be destroyed either because of truncate - at that point there's no risk of anyone else looking at that page for directories (i_rwsem) - or because of page reclaim - at which point we are guaranteed nobody else holds a reference to the page and new reference cannot be acquired.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR