Skip to content

Commit aa405b1

Browse files
committed
nilfs2: always set back pointer to host inode in mapping->host
In the current nilfs, page cache for btree nodes and meta data files do not set a valid back pointer to the host inode in mapping->host. This will change it so that every address space in nilfs uses mapping->host to hold its host inode. Signed-off-by: Ryusuke Konishi <[email protected]>
1 parent 0ef28f9 commit aa405b1

File tree

8 files changed

+14
-36
lines changed

8 files changed

+14
-36
lines changed

fs/nilfs2/btnode.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
#include "page.h"
3535
#include "btnode.h"
3636

37-
void nilfs_btnode_cache_init(struct address_space *btnc,
38-
struct backing_dev_info *bdi)
39-
{
40-
nilfs_mapping_init(btnc, bdi);
41-
}
42-
4337
void nilfs_btnode_cache_clear(struct address_space *btnc)
4438
{
4539
invalidate_mapping_pages(btnc, 0, -1);

fs/nilfs2/btnode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct nilfs_btnode_chkey_ctxt {
3737
struct buffer_head *newbh;
3838
};
3939

40-
void nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *);
4140
void nilfs_btnode_cache_clear(struct address_space *);
4241
struct buffer_head *nilfs_btnode_create_block(struct address_space *btnc,
4342
__u64 blocknr);

fs/nilfs2/mdt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ int nilfs_mdt_setup_shadow_map(struct inode *inode,
450450

451451
INIT_LIST_HEAD(&shadow->frozen_buffers);
452452
address_space_init_once(&shadow->frozen_data);
453-
nilfs_mapping_init(&shadow->frozen_data, bdi);
453+
nilfs_mapping_init(&shadow->frozen_data, inode, bdi);
454454
address_space_init_once(&shadow->frozen_btnodes);
455-
nilfs_mapping_init(&shadow->frozen_btnodes, bdi);
455+
nilfs_mapping_init(&shadow->frozen_btnodes, inode, bdi);
456456
mi->mi_shadow = shadow;
457457
return 0;
458458
}

fs/nilfs2/nilfs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ static inline struct inode *NILFS_BTNC_I(struct address_space *btnc)
8080
return &ii->vfs_inode;
8181
}
8282

83-
static inline struct inode *NILFS_AS_I(struct address_space *mapping)
84-
{
85-
return (mapping->host) ? :
86-
container_of(mapping, struct inode, i_data);
87-
}
88-
8983
/*
9084
* Dynamic state flags of NILFS on-memory inode (i_state)
9185
*/

fs/nilfs2/page.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,16 @@ int nilfs_page_buffers_clean(struct page *page)
182182
void nilfs_page_bug(struct page *page)
183183
{
184184
struct address_space *m;
185-
unsigned long ino = 0;
185+
unsigned long ino;
186186

187187
if (unlikely(!page)) {
188188
printk(KERN_CRIT "NILFS_PAGE_BUG(NULL)\n");
189189
return;
190190
}
191191

192192
m = page->mapping;
193-
if (m) {
194-
struct inode *inode = NILFS_AS_I(m);
195-
if (inode != NULL)
196-
ino = inode->i_ino;
197-
}
193+
ino = m ? m->host->i_ino : 0;
194+
198195
printk(KERN_CRIT "NILFS_PAGE_BUG(%p): cnt=%d index#=%llu flags=0x%lx "
199196
"mapping=%p ino=%lu\n",
200197
page, atomic_read(&page->_count),
@@ -441,10 +438,10 @@ unsigned nilfs_page_count_clean_buffers(struct page *page,
441438
return nc;
442439
}
443440

444-
void nilfs_mapping_init(struct address_space *mapping,
441+
void nilfs_mapping_init(struct address_space *mapping, struct inode *inode,
445442
struct backing_dev_info *bdi)
446443
{
447-
mapping->host = NULL;
444+
mapping->host = inode;
448445
mapping->flags = 0;
449446
mapping_set_gfp_mask(mapping, GFP_NOFS);
450447
mapping->assoc_mapping = NULL;

fs/nilfs2/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void nilfs_page_bug(struct page *);
5757
int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
5858
void nilfs_copy_back_pages(struct address_space *, struct address_space *);
5959
void nilfs_clear_dirty_pages(struct address_space *);
60-
void nilfs_mapping_init(struct address_space *mapping,
60+
void nilfs_mapping_init(struct address_space *mapping, struct inode *inode,
6161
struct backing_dev_info *bdi);
6262
unsigned nilfs_page_count_clean_buffers(struct page *, unsigned, unsigned);
6363
unsigned long nilfs_find_uncommitted_extent(struct inode *inode,

fs/nilfs2/segment.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,10 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
655655
if (unlikely(page->index > last))
656656
break;
657657

658-
if (mapping->host) {
659-
lock_page(page);
660-
if (!page_has_buffers(page))
661-
create_empty_buffers(page,
662-
1 << inode->i_blkbits, 0);
663-
unlock_page(page);
664-
}
658+
lock_page(page);
659+
if (!page_has_buffers(page))
660+
create_empty_buffers(page, 1 << inode->i_blkbits, 0);
661+
unlock_page(page);
665662

666663
bh = head = page_buffers(page);
667664
do {
@@ -1503,10 +1500,7 @@ nilfs_segctor_update_payload_blocknr(struct nilfs_sc_info *sci,
15031500
nblocks = le32_to_cpu(finfo->fi_nblocks);
15041501
ndatablk = le32_to_cpu(finfo->fi_ndatablk);
15051502

1506-
if (buffer_nilfs_node(bh))
1507-
inode = NILFS_BTNC_I(bh->b_page->mapping);
1508-
else
1509-
inode = NILFS_AS_I(bh->b_page->mapping);
1503+
inode = bh->b_page->mapping->host;
15101504

15111505
if (mode == SC_LSEG_DSYNC)
15121506
sc_op = &nilfs_sc_dsync_ops;

fs/nilfs2/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct inode *nilfs_alloc_inode(struct super_block *sb)
166166
ii->i_state = 0;
167167
ii->i_cno = 0;
168168
ii->vfs_inode.i_version = 1;
169-
nilfs_btnode_cache_init(&ii->i_btnode_cache, sb->s_bdi);
169+
nilfs_mapping_init(&ii->i_btnode_cache, &ii->vfs_inode, sb->s_bdi);
170170
return &ii->vfs_inode;
171171
}
172172

0 commit comments

Comments
 (0)