Skip to contentSkip to conversation

fs/open.c: use ->f_mapping instead of ->f_mapping->host->i_mapping

PATCH In review Eric Biggers 2 participants 2 messages Mar 26, 2017 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/open.c: use ->f_mapping instead of ->f_mapping->host->i_mapping

From: Eric Biggers <[email protected]>

In do_dentry_open(), initialize the readahead state using ->f_mapping instead of ->f_mapping->host->i_mapping. This is equivalent, even for block device files; we don't need the extra indirection because ->f_mapping already represents the data read/written by the file (which for block device nodes is the underlying block device mapping).

---
 fs/open.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/open.c +1 -1
index 949cef29c3bb..32e19fda24d2 100644
@@ -763,7 +763,7 @@ static int do_dentry_open(struct file *f,
 
 	f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
 
-	file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
+	file_ra_state_init(&f->f_ra, f->f_mapping);
 
 	return 0;
 
Signature · 1 line
2.12.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Eric Biggers

From: Eric Biggers <[email protected]>

In do_dentry_open(), initialize the readahead state using ->f_mapping instead of ->f_mapping->host->i_mapping. This is equivalent, even for block device files; we don't need the extra indirection because ->f_mapping already represents the data read/written by the file (which for block device nodes is the underlying block device mapping).

---
 fs/open.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/open.c +0 -0
index 949cef29c3bb..32e19fda24d2 100644

fs/open.c static int do_dentry_open(struct file *f, · line 769

Quoted 8 lines
fs/open.c +1 -1
@@ -763,7 +763,7 @@ static int do_dentry_open(struct file *f,
 
 	f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
 
-	file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
+	file_ra_state_init(&f->f_ra, f->f_mapping);
 
 	return 0;
 

(cc'ing David Howells...)

Yeah, that certainly looks circular to me.

I was chatting with David the other day, and I asked him a similar
question: When is f_mapping set to anything else other than what this would point to?

    filp->f_path.dentry->d_inode->i_mapping

It seems like we might not need f_mapping at all, though David seemed to think that coda might sometimes set it to something different. Do you have any insight there?

In any case: