nilfs2: eliminate kmap and kmap_atomic calls
Ryusuke Konishi
maintainercover nilfs2: eliminate kmap and kmap_atomic calls
Hi Andrew,
Please queue this series for the next merge window.
This series converts remaining kmap and kmap_atomic calls to use kmap_local, mainly in metadata files, and eliminates calls to these deprecated kmap functions from nilfs2.
This series does not include converting metadata files to use folios, but it is a step in that direction.
Most conversions are straightforward, but some are not: the checkpoint file, the inode file, and the persistent object allocator. These have been adjusted or rewritten to avoid multiple kmap_local calls or nest them if necessary, and to eliminate long waits like block I/O within the highmem mapping sections.
This series has been tested in both 32-bit and 64-bit environments with varying block sizes.
Thanks,
Ryusuke Konishi
Ryusuke Konishi (15):
nilfs2: convert recovery logic to use kmap_local
nilfs2: convert segment buffer to use kmap_local
nilfs2: convert nilfs_copy_buffer() to use kmap_local
nilfs2: convert metadata file common code to use kmap_local
nilfs2: convert sufile to use kmap_local
nilfs2: convert persistent object allocator to use kmap_local
nilfs2: convert DAT to use kmap_local
nilfs2: move nilfs_bmap_write call out of nilfs_write_inode_common
nilfs2: do not acquire rwsem in nilfs_bmap_write()
nilfs2: convert ifile to use kmap_local
nilfs2: localize highmem mapping for checkpoint creation within cpfile
nilfs2: localize highmem mapping for checkpoint finalization within
cpfile
nilfs2: localize highmem mapping for checkpoint reading within cpfile
nilfs2: remove nilfs_cpfile_{get,put}_checkpoint()
nilfs2: convert cpfile to use kmap_local
fs/nilfs2/alloc.c | 91 ++++++------ fs/nilfs2/bmap.c | 3 - fs/nilfs2/cpfile.c | 319 +++++++++++++++++++++++++++++-------------- fs/nilfs2/cpfile.h | 10 +- fs/nilfs2/dat.c | 38 +++--- fs/nilfs2/ifile.c | 21 +-- fs/nilfs2/ifile.h | 10 +- fs/nilfs2/inode.c | 44 +++--- fs/nilfs2/mdt.c | 4 +- fs/nilfs2/nilfs.h | 3 +- fs/nilfs2/page.c | 8 +- fs/nilfs2/recovery.c | 4 +- fs/nilfs2/segbuf.c | 4 +- fs/nilfs2/segment.c | 121 ++++++---------- fs/nilfs2/sufile.c | 86 ++++++------ fs/nilfs2/super.c | 31 +---- 16 files changed, 425 insertions(+), 372 deletions(-)
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 1/15 nilfs2: convert recovery logic to use kmap_local
In the recovery function when mounting, nilfs_recovery_copy_block() uses the deprecated kmap_atomic(), so convert it to use kmap_local.
--- fs/nilfs2/recovery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/recovery.c +2 -2
@@ -481,9 +481,9 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,if (unlikely (!bh_org))return -EIO ; - kaddr =kmap_atomic (page); + kaddr =kmap_local_page (page);memcpy (kaddr +bh_offset (bh_org), bh_org->b_data, bh_org->b_size); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh_org);return 0 ; }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 2/15 nilfs2: convert segment buffer to use kmap_local
In reply to Ryusuke KonishiIn the segment buffer code used for log writing, a CRC calculation routine uses the deprecated kmap_atomic(), so convert it to use kmap_local.
--- fs/nilfs2/segbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/segbuf.c +2 -2
@@ -220,9 +220,9 @@ static void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf, crc =crc32_le (crc, bh->b_data, bh->b_size); }list_for_each_entry (bh, &segbuf->sb_payload_buffers, b_assoc_buffers) { - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); crc =crc32_le (crc, kaddr +bh_offset (bh), bh->b_size); -kunmap_atomic (kaddr); +kunmap_local (kaddr); } raw_sum->ss_datasum =cpu_to_le32 (crc); }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 3/15 nilfs2: convert nilfs_copy_buffer() to use kmap_local
In reply to Ryusuke KonishiThe routine nilfs_copy_buffer() that copies a block buffer still uses the deprecated kmap_atomic(), so convert it to use kmap_local.
--- fs/nilfs2/page.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nilfs2/page.c +4 -4
@@ -103,11 +103,11 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)struct page *spage = sbh->b_page, *dpage = dbh->b_page;struct buffer_head *bh; - kaddr0 =kmap_atomic (spage); - kaddr1 =kmap_atomic (dpage); + kaddr0 =kmap_local_page (spage); + kaddr1 =kmap_local_page (dpage);memcpy (kaddr1 +bh_offset (dbh), kaddr0 +bh_offset (sbh), sbh->b_size); -kunmap_atomic (kaddr1); -kunmap_atomic (kaddr0); +kunmap_local (kaddr1); +kunmap_local (kaddr0); dbh->b_state = sbh->b_state &NILFS_BUFFER_INHERENT_BITS ; dbh->b_blocknr = sbh->b_blocknr;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 4/15 nilfs2: convert metadata file common code to use kmap_local
In reply to Ryusuke KonishiIn the common code of metadata files, the new block creation routine nilfs_mdt_insert_new_block() still uses the deprecated kmap_atomic(), so convert it to use kmap_local.
--- fs/nilfs2/mdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/mdt.c +2 -2
@@ -47,12 +47,12 @@ nilfs_mdt_insert_new_block(struct inode *inode, unsigned long block,set_buffer_mapped (bh); - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page);memset (kaddr +bh_offset (bh),0 ,i_blocksize (inode));if (init_block)init_block (inode, bh, kaddr);flush_dcache_page (bh->b_page); -kunmap_atomic (kaddr); +kunmap_local (kaddr);set_buffer_uptodate (bh);mark_buffer_dirty (bh);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 5/15 nilfs2: convert sufile to use kmap_local
In reply to Ryusuke KonishiConcerning the code of the metadata file sufile for segment management, convert all parts that uses the deprecated kmap_atomic() to use kmap_local. All transformations are directly possible here.
--- fs/nilfs2/sufile.c | 86 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-)
fs/nilfs2/sufile.c +43 -43
@@ -107,11 +107,11 @@ static void nilfs_sufile_mod_counter(struct buffer_head *header_bh,struct nilfs_sufile_header *header;void *kaddr; - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header = kaddr +bh_offset (header_bh);le64_add_cpu (&header->sh_ncleansegs, ncleanadd);le64_add_cpu (&header->sh_ndirtysegs, ndirtyadd); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (header_bh); }
@@ -315,10 +315,10 @@ int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) ret =nilfs_sufile_get_header_block (sufile, &header_bh);if (ret <0 ) goto out_sem; - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header = kaddr +bh_offset (header_bh); last_alloc =le64_to_cpu (header->sh_last_alloc); -kunmap_atomic (kaddr); +kunmap_local (kaddr); nsegments =nilfs_sufile_get_nsegments (sufile); maxsegnum = sui->allocmax;
@@ -352,7 +352,7 @@ int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) &su_bh);if (ret <0 ) goto out_header; - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage ( sufile, segnum, su_bh, kaddr);
@@ -363,14 +363,14 @@ int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump)continue ;/* found a clean segment */ nilfs_segment_usage_set_dirty (su); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header = kaddr +bh_offset (header_bh);le64_add_cpu (&header->sh_ncleansegs,-1 );le64_add_cpu (&header->sh_ndirtysegs,1 ); header->sh_last_alloc =cpu_to_le64 (segnum); -kunmap_atomic (kaddr); +kunmap_local (kaddr); sui->ncleansegs--;mark_buffer_dirty (header_bh);
@@ -384,7 +384,7 @@ int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) goto out_header; } -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (su_bh); }
@@ -406,16 +406,16 @@ void nilfs_sufile_do_cancel_free(struct inode *sufile, __u64 segnum,struct nilfs_segment_usage *su;void *kaddr; - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, su_bh, kaddr);if (unlikely (!nilfs_segment_usage_clean (su))) {nilfs_warn (sufile->i_sb,"%s: segment %llu must be clean" , __func__, (unsigned long long )segnum); -kunmap_atomic (kaddr); +kunmap_local (kaddr);return ; }nilfs_segment_usage_set_dirty (su); -kunmap_atomic (kaddr); +kunmap_local (kaddr);nilfs_sufile_mod_counter (header_bh,-1 ,1 );NILFS_SUI (sufile)->ncleansegs--;
@@ -432,11 +432,11 @@ void nilfs_sufile_do_scrap(struct inode *sufile, __u64 segnum,void *kaddr;int clean, dirty; - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, su_bh, kaddr);if (su->su_flags ==cpu_to_le32 (BIT (NILFS_SEGMENT_USAGE_DIRTY )) && su->su_nblocks ==cpu_to_le32 (0 )) { -kunmap_atomic (kaddr); +kunmap_local (kaddr);return ; } clean =nilfs_segment_usage_clean (su);
@@ -446,7 +446,7 @@ void nilfs_sufile_do_scrap(struct inode *sufile, __u64 segnum, su->su_lastmod =cpu_to_le64 (0 ); su->su_nblocks =cpu_to_le32 (0 ); su->su_flags =cpu_to_le32 (BIT (NILFS_SEGMENT_USAGE_DIRTY )); -kunmap_atomic (kaddr); +kunmap_local (kaddr);nilfs_sufile_mod_counter (header_bh, clean ? (u64)-1 :0 , dirty ?0 :1 );NILFS_SUI (sufile)->ncleansegs -= clean;
@@ -463,12 +463,12 @@ void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum,void *kaddr;int sudirty; - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, su_bh, kaddr);if (nilfs_segment_usage_clean (su)) {nilfs_warn (sufile->i_sb,"%s: segment %llu is already clean" , __func__, (unsigned long long )segnum); -kunmap_atomic (kaddr); +kunmap_local (kaddr);return ; }if (unlikely (nilfs_segment_usage_error (su)))
@@ -481,7 +481,7 @@ void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum, (unsigned long long)segnum);nilfs_segment_usage_set_clean (su); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (su_bh);nilfs_sufile_mod_counter (header_bh,1 , sudirty ? (u64)-1 :0 );
@@ -509,12 +509,12 @@ int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum)if (ret) goto out_sem; - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, bh, kaddr);if (unlikely (nilfs_segment_usage_error (su))) {struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh);if (nilfs_segment_is_active (nilfs, segnum)) { nilfs_error(sufile->i_sb,
@@ -532,7 +532,7 @@ int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum) ret = -EIO ; }else {nilfs_segment_usage_set_dirty (su); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (bh);nilfs_mdt_mark_dirty (sufile);brelse (bh);
@@ -562,7 +562,7 @@ int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum,if (ret <0 ) goto out_sem; - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, bh, kaddr);if (modtime) {/*
@@ -573,7 +573,7 @@ int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, su->su_lastmod =cpu_to_le64 (modtime); } su->su_nblocks =cpu_to_le32 (nblocks); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (bh);nilfs_mdt_mark_dirty (sufile);
@@ -614,7 +614,7 @@ int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat)if (ret <0 ) goto out_sem; - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header = kaddr +bh_offset (header_bh); sustat->ss_nsegs =nilfs_sufile_get_nsegments (sufile); sustat->ss_ncleansegs =le64_to_cpu (header->sh_ncleansegs);
@@ -624,7 +624,7 @@ int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat)spin_lock (&nilfs->ns_last_segment_lock); sustat->ss_prot_seq = nilfs->ns_prot_seq;spin_unlock (&nilfs->ns_last_segment_lock); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (header_bh); out_sem:
@@ -640,15 +640,15 @@ void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum,void *kaddr;int suclean; - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, su_bh, kaddr);if (nilfs_segment_usage_error (su)) { -kunmap_atomic (kaddr); +kunmap_local (kaddr);return ; } suclean =nilfs_segment_usage_clean (su);nilfs_segment_usage_set_error (su); -kunmap_atomic (kaddr); +kunmap_local (kaddr);if (suclean) {nilfs_sufile_mod_counter (header_bh,-1 ,0 );
@@ -717,7 +717,7 @@ static int nilfs_sufile_truncate_range(struct inode *sufile,/* hole */ continue ; } - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage ( sufile, segnum, su_bh, kaddr); su2 = su;
@@ -726,7 +726,7 @@ static int nilfs_sufile_truncate_range(struct inode *sufile, ~BIT(NILFS_SEGMENT_USAGE_ERROR)) || nilfs_segment_is_active(nilfs, segnum + j)) { ret = -EBUSY ; -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (su_bh); goto out_header; }
@@ -738,7 +738,7 @@ static int nilfs_sufile_truncate_range(struct inode *sufile, nc++; } } -kunmap_atomic (kaddr); +kunmap_local (kaddr);if (nc >0 ) {mark_buffer_dirty (su_bh); ncleaned += nc;
@@ -823,10 +823,10 @@ int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs) sui->allocmin =0 ; } - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header = kaddr +bh_offset (header_bh); header->sh_ncleansegs =cpu_to_le64 (sui->ncleansegs); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (header_bh);nilfs_mdt_mark_dirty (sufile);
@@ -891,7 +891,7 @@ ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf,continue ; } - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage ( sufile, segnum, su_bh, kaddr); for (j = 0; j < n;
@@ -904,7 +904,7 @@ ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf, si->sui_flags |=BIT (NILFS_SEGMENT_USAGE_ACTIVE ); } -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (su_bh); } ret = nsegs;
@@ -973,7 +973,7 @@ ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf, goto out_header;for (;;) { - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); su =nilfs_sufile_block_get_segment_usage ( sufile, sup->sup_segnum, bh, kaddr);
@@ -1010,7 +1010,7 @@ ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf, su->su_flags =cpu_to_le32 (sup->sup_sui.sui_flags); } -kunmap_atomic (kaddr); +kunmap_local (kaddr); sup = (void *)sup + supsz;if (sup >= supend)
@@ -1115,7 +1115,7 @@ int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range)continue ; } - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage (sufile, segnum, su_bh, kaddr);for (i =0 ; i < n; ++i, ++segnum, su = (void *)su + susz) {
@@ -1145,7 +1145,7 @@ int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range) }if (nblocks >= minlen) { -kunmap_atomic (kaddr); +kunmap_local (kaddr); ret = blkdev_issue_discard(nilfs->ns_bdev, start * sects_per_block,
@@ -1157,7 +1157,7 @@ int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range) } ndiscarded += nblocks; - kaddr =kmap_atomic (su_bh->b_page); + kaddr =kmap_local_page (su_bh->b_page); su =nilfs_sufile_block_get_segment_usage ( sufile, segnum, su_bh, kaddr); }
@@ -1166,7 +1166,7 @@ int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range) start = seg_start; nblocks = seg_end - seg_start +1 ; } -kunmap_atomic (kaddr); +kunmap_local (kaddr);put_bh (su_bh); }
@@ -1246,10 +1246,10 @@ int nilfs_sufile_read(struct super_block *sb, size_t susize, goto failed; sui =NILFS_SUI (sufile); - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header = kaddr +bh_offset (header_bh); sui->ncleansegs =le64_to_cpu (header->sh_ncleansegs); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (header_bh); sui->allocmax =nilfs_sufile_get_nsegments (sufile) -1 ;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 6/15 nilfs2: convert persistent object allocator to use kmap_local
In reply to Ryusuke KonishiRegarding the allocator code that is commonly used in the ondisk inode metadata file ifile and the disk address translation metadata file DAT, convert the parts that use the deprecated kmap_atomic() and kmap() to use kmap_local.
Most can be converted directly, but only nilfs_palloc_prepare_alloc_entry() needs to be rewritten to change mapping sections so that multiple kmap_local/kunmap_local calls are nested and disk I/O can be avoided within the mapping sections.
--- fs/nilfs2/alloc.c | 91 ++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 45 deletions(-)
fs/nilfs2/alloc.c +46 -45
@@ -525,54 +525,55 @@ int nilfs_palloc_prepare_alloc_entry(struct inode *inode, ret =nilfs_palloc_get_desc_block (inode, group,1 , &desc_bh);if (ret <0 )return ret; - desc_kaddr =kmap (desc_bh->b_page); + desc_kaddr =kmap_local_page (desc_bh->b_page); desc =nilfs_palloc_block_get_group_desc ( inode, group, desc_bh, desc_kaddr); n =nilfs_palloc_rest_groups_in_desc_block (inode, group, maxgroup); -for (j =0 ; j < n; j++, desc++, group++) { +for (j =0 ; j < n; j++, desc++, group++, group_offset =0 ) { lock =nilfs_mdt_bgl_lock (inode, group); -if (nilfs_palloc_group_desc_nfrees (desc, lock) >0 ) { - ret =nilfs_palloc_get_bitmap_block ( - inode, group,1 , &bitmap_bh); -if (ret <0 ) - goto out_desc; - bitmap_kaddr =kmap (bitmap_bh->b_page); - bitmap = bitmap_kaddr +bh_offset (bitmap_bh); - pos =nilfs_palloc_find_available_slot ( - bitmap, group_offset, - entries_per_group, lock); -if (pos >=0 ) { -/* found a free entry */ -nilfs_palloc_group_desc_add_entries ( - desc, lock,-1 ); - req->pr_entry_nr = - entries_per_group * group + pos; -kunmap (desc_bh->b_page); -kunmap (bitmap_bh->b_page); - - req->pr_desc_bh = desc_bh; - req->pr_bitmap_bh = bitmap_bh; -return 0 ; - } -kunmap (bitmap_bh->b_page); -brelse (bitmap_bh); +if (nilfs_palloc_group_desc_nfrees (desc, lock) ==0 ) +continue ; + +kunmap_local (desc_kaddr); + ret =nilfs_palloc_get_bitmap_block (inode, group,1 , + &bitmap_bh); +if (unlikely (ret <0 )) { +brelse (desc_bh); +return ret; } - group_offset =0 ; + desc_kaddr =kmap_local_page (desc_bh->b_page); + desc =nilfs_palloc_block_get_group_desc ( + inode, group, desc_bh, desc_kaddr); + + bitmap_kaddr =kmap_local_page (bitmap_bh->b_page); + bitmap = bitmap_kaddr +bh_offset (bitmap_bh); + pos =nilfs_palloc_find_available_slot ( + bitmap, group_offset, entries_per_group, lock); +kunmap_local (bitmap_kaddr); +if (pos >=0 ) + goto found; + +brelse (bitmap_bh); } -kunmap (desc_bh->b_page); +kunmap_local (desc_kaddr);brelse (desc_bh); }/* no entries left */ return -ENOSPC ; - out_desc: -kunmap (desc_bh->b_page); -brelse (desc_bh); -return ret; +found: +/* found a free entry */ +nilfs_palloc_group_desc_add_entries (desc, lock,-1 ); + req->pr_entry_nr = entries_per_group * group + pos; +kunmap_local (desc_kaddr); + + req->pr_desc_bh = desc_bh; + req->pr_bitmap_bh = bitmap_bh; +return 0 ; }/**
@@ -606,10 +607,10 @@ void nilfs_palloc_commit_free_entry(struct inode *inode,spinlock_t *lock; group =nilfs_palloc_group (inode, req->pr_entry_nr, &group_offset); - desc_kaddr =kmap (req->pr_desc_bh->b_page); + desc_kaddr =kmap_local_page (req->pr_desc_bh->b_page); desc =nilfs_palloc_block_get_group_desc (inode, group, req->pr_desc_bh, desc_kaddr); - bitmap_kaddr =kmap (req->pr_bitmap_bh->b_page); + bitmap_kaddr =kmap_local_page (req->pr_bitmap_bh->b_page); bitmap = bitmap_kaddr +bh_offset (req->pr_bitmap_bh); lock =nilfs_mdt_bgl_lock (inode, group);
@@ -621,8 +622,8 @@ void nilfs_palloc_commit_free_entry(struct inode *inode,else nilfs_palloc_group_desc_add_entries (desc, lock,1 ); -kunmap (req->pr_bitmap_bh->b_page); -kunmap (req->pr_desc_bh->b_page); +kunmap_local (bitmap_kaddr); +kunmap_local (desc_kaddr);mark_buffer_dirty (req->pr_desc_bh);mark_buffer_dirty (req->pr_bitmap_bh);
@@ -647,10 +648,10 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode,spinlock_t *lock; group =nilfs_palloc_group (inode, req->pr_entry_nr, &group_offset); - desc_kaddr =kmap (req->pr_desc_bh->b_page); + desc_kaddr =kmap_local_page (req->pr_desc_bh->b_page); desc =nilfs_palloc_block_get_group_desc (inode, group, req->pr_desc_bh, desc_kaddr); - bitmap_kaddr =kmap (req->pr_bitmap_bh->b_page); + bitmap_kaddr =kmap_local_page (req->pr_bitmap_bh->b_page); bitmap = bitmap_kaddr +bh_offset (req->pr_bitmap_bh); lock =nilfs_mdt_bgl_lock (inode, group);
@@ -662,8 +663,8 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode,else nilfs_palloc_group_desc_add_entries (desc, lock,1 ); -kunmap (req->pr_bitmap_bh->b_page); -kunmap (req->pr_desc_bh->b_page); +kunmap_local (bitmap_kaddr); +kunmap_local (desc_kaddr);brelse (req->pr_bitmap_bh);brelse (req->pr_desc_bh);
@@ -755,7 +756,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)/* Get the first entry number of the group */ group_min_nr = (__u64 )group * epg; - bitmap_kaddr =kmap (bitmap_bh->b_page); + bitmap_kaddr =kmap_local_page (bitmap_bh->b_page); bitmap = bitmap_kaddr +bh_offset (bitmap_bh); lock =nilfs_mdt_bgl_lock (inode, group);
@@ -801,7 +802,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) entry_start =rounddown (group_offset, epb); }while (true); -kunmap (bitmap_bh->b_page); +kunmap_local (bitmap_kaddr);mark_buffer_dirty (bitmap_bh);brelse (bitmap_bh);
@@ -815,11 +816,11 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) inode->i_ino); } - desc_kaddr =kmap_atomic (desc_bh->b_page); + desc_kaddr =kmap_local_page (desc_bh->b_page); desc =nilfs_palloc_block_get_group_desc ( inode, group, desc_bh, desc_kaddr); nfree =nilfs_palloc_group_desc_add_entries (desc, lock, n); -kunmap_atomic (desc_kaddr); +kunmap_local (desc_kaddr);mark_buffer_dirty (desc_bh);nilfs_mdt_mark_dirty (inode);brelse (desc_bh);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 7/15 nilfs2: convert DAT to use kmap_local
In reply to Ryusuke KonishiConcerning the code of the metadata file DAT for disk address translation, convert all parts that use the deprecated kmap_atomic to use kmap_local. All transformations are directly possible.
--- fs/nilfs2/dat.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
fs/nilfs2/dat.c +19 -19
@@ -91,13 +91,13 @@ void nilfs_dat_commit_alloc(struct inode *dat, struct nilfs_palloc_req *req)struct nilfs_dat_entry *entry;void *kaddr; - kaddr =kmap_atomic (req->pr_entry_bh->b_page); + kaddr =kmap_local_page (req->pr_entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, req->pr_entry_nr, req->pr_entry_bh, kaddr); entry->de_start =cpu_to_le64 (NILFS_CNO_MIN ); entry->de_end =cpu_to_le64 (NILFS_CNO_MAX ); entry->de_blocknr =cpu_to_le64 (0 ); -kunmap_atomic (kaddr); +kunmap_local (kaddr);nilfs_palloc_commit_alloc_entry (dat, req);nilfs_dat_commit_entry (dat, req);
@@ -115,13 +115,13 @@ static void nilfs_dat_commit_free(struct inode *dat,struct nilfs_dat_entry *entry;void *kaddr; - kaddr =kmap_atomic (req->pr_entry_bh->b_page); + kaddr =kmap_local_page (req->pr_entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, req->pr_entry_nr, req->pr_entry_bh, kaddr); entry->de_start =cpu_to_le64 (NILFS_CNO_MIN ); entry->de_end =cpu_to_le64 (NILFS_CNO_MIN ); entry->de_blocknr =cpu_to_le64 (0 ); -kunmap_atomic (kaddr); +kunmap_local (kaddr);nilfs_dat_commit_entry (dat, req);
@@ -145,12 +145,12 @@ void nilfs_dat_commit_start(struct inode *dat, struct nilfs_palloc_req *req,struct nilfs_dat_entry *entry;void *kaddr; - kaddr =kmap_atomic (req->pr_entry_bh->b_page); + kaddr =kmap_local_page (req->pr_entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, req->pr_entry_nr, req->pr_entry_bh, kaddr); entry->de_start =cpu_to_le64 (nilfs_mdt_cno (dat)); entry->de_blocknr =cpu_to_le64 (blocknr); -kunmap_atomic (kaddr); +kunmap_local (kaddr);nilfs_dat_commit_entry (dat, req); }
@@ -167,12 +167,12 @@ int nilfs_dat_prepare_end(struct inode *dat, struct nilfs_palloc_req *req)if (ret <0 )return ret; - kaddr =kmap_atomic (req->pr_entry_bh->b_page); + kaddr =kmap_local_page (req->pr_entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, req->pr_entry_nr, req->pr_entry_bh, kaddr); start =le64_to_cpu (entry->de_start); blocknr =le64_to_cpu (entry->de_blocknr); -kunmap_atomic (kaddr); +kunmap_local (kaddr);if (blocknr ==0 ) { ret =nilfs_palloc_prepare_free_entry (dat, req);
@@ -202,7 +202,7 @@ void nilfs_dat_commit_end(struct inode *dat, struct nilfs_palloc_req *req,sector_t blocknr;void *kaddr; - kaddr =kmap_atomic (req->pr_entry_bh->b_page); + kaddr =kmap_local_page (req->pr_entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, req->pr_entry_nr, req->pr_entry_bh, kaddr); end = start =le64_to_cpu (entry->de_start);
@@ -212,7 +212,7 @@ void nilfs_dat_commit_end(struct inode *dat, struct nilfs_palloc_req *req, } entry->de_end =cpu_to_le64 (end); blocknr =le64_to_cpu (entry->de_blocknr); -kunmap_atomic (kaddr); +kunmap_local (kaddr);if (blocknr ==0 )nilfs_dat_commit_free (dat, req);
@@ -227,12 +227,12 @@ void nilfs_dat_abort_end(struct inode *dat, struct nilfs_palloc_req *req)sector_t blocknr;void *kaddr; - kaddr =kmap_atomic (req->pr_entry_bh->b_page); + kaddr =kmap_local_page (req->pr_entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, req->pr_entry_nr, req->pr_entry_bh, kaddr); start =le64_to_cpu (entry->de_start); blocknr =le64_to_cpu (entry->de_blocknr); -kunmap_atomic (kaddr); +kunmap_local (kaddr);if (start ==nilfs_mdt_cno (dat) && blocknr ==0 )nilfs_palloc_abort_free_entry (dat, req);
@@ -362,7 +362,7 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr) } } - kaddr =kmap_atomic (entry_bh->b_page); + kaddr =kmap_local_page (entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, vblocknr, entry_bh, kaddr);if (unlikely (entry->de_blocknr ==cpu_to_le64 (0 ))) { nilfs_crit(dat->i_sb,
@@ -370,13 +370,13 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr) __func__, (unsigned long long )vblocknr, (unsigned long long )le64_to_cpu (entry->de_start), (unsigned long long)le64_to_cpu(entry->de_end)); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (entry_bh);return -EINVAL ; }WARN_ON (blocknr ==0 ); entry->de_blocknr =cpu_to_le64 (blocknr); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (entry_bh);nilfs_mdt_mark_dirty (dat);
@@ -426,7 +426,7 @@ int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) } } - kaddr =kmap_atomic (entry_bh->b_page); + kaddr =kmap_local_page (entry_bh->b_page); entry =nilfs_palloc_block_get_entry (dat, vblocknr, entry_bh, kaddr); blocknr =le64_to_cpu (entry->de_blocknr);if (blocknr ==0 ) {
@@ -436,7 +436,7 @@ int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) *blocknrp = blocknr; out: -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (entry_bh);return ret; }
@@ -457,7 +457,7 @@ ssize_t nilfs_dat_get_vinfo(struct inode *dat, void *buf, unsigned int visz, 0, &entry_bh);if (ret <0 )return ret; - kaddr =kmap_atomic (entry_bh->b_page); + kaddr =kmap_local_page (entry_bh->b_page);/* last virtual block number in this block */ first = vinfo->vi_vblocknr;do_div (first, entries_per_block);
@@ -473,7 +473,7 @@ ssize_t nilfs_dat_get_vinfo(struct inode *dat, void *buf, unsigned int visz, vinfo->vi_end =le64_to_cpu (entry->de_end); vinfo->vi_blocknr =le64_to_cpu (entry->de_blocknr); } -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (entry_bh); }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 8/15 nilfs2: move nilfs_bmap_write call out of nilfs_write_inode_common
In reply to Ryusuke KonishiBefore converting the disk inode management metadata file ifile, the call to nilfs_bmap_write(), the i_device_code setting, and the zero-fill code for inodes on the super root block are moved from nilfs_write_inode_common() to its callers.
This cleanup simplifies the role and arguments of nilfs_write_inode_common() and collects calls to nilfs_bmap_write() to the log writing code.
Also, add and use a new helper nilfs_write_root_mdt_inode() to avoid code duplication in the data export routine nilfs_segctor_fill_in_super_root() to the super root block's buffer.
--- fs/nilfs2/inode.c | 38 +++++++++++++++--------------------- fs/nilfs2/nilfs.h | 3 ++- fs/nilfs2/segment.c | 47 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 31 deletions(-)
fs/nilfs2/inode.c +16 -22
@@ -759,8 +759,18 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode)return s_inode; } +/** +* nilfs_write_inode_common - export common inode information to on-disk inode +* @inode: inode object +* @raw_inode: on-disk inode +* +* This function writes standard information from the on-memory inode @inode +* to @raw_inode on ifile, cpfile or a super root block. Since inode bmap +* data is not exported, nilfs_bmap_write() must be called separately during +* log writing. +*/ void nilfs_write_inode_common (struct inode *inode, -struct nilfs_inode *raw_inode,int has_bmap) +struct nilfs_inode *raw_inode) {struct nilfs_inode_info *ii =NILFS_I (inode);
@@ -778,21 +788,6 @@ void nilfs_write_inode_common(struct inode *inode, raw_inode->i_flags =cpu_to_le32 (ii->i_flags); raw_inode->i_generation =cpu_to_le32 (inode->i_generation); -if (NILFS_ROOT_METADATA_FILE (inode->i_ino)) { -struct the_nilfs *nilfs = inode->i_sb->s_fs_info; - -/* zero-fill unused portion in the case of super root block */ - raw_inode->i_xattr =0 ; - raw_inode->i_pad =0 ; -memset ((void *)raw_inode +sizeof (*raw_inode),0 , - nilfs->ns_inode_size -sizeof (*raw_inode)); - } - -if (has_bmap) -nilfs_bmap_write (ii->i_bmap, raw_inode); -else if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) - raw_inode->i_device_code = -cpu_to_le64 (huge_encode_dev (inode->i_rdev));/* * When extending inode, nilfs->ns_inode_size should be checked * for substitutions of appended fields.
@@ -813,12 +808,11 @@ void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh, int flags)if (flags &I_DIRTY_DATASYNC )set_bit (NILFS_I_INODE_SYNC , &ii->i_state); -nilfs_write_inode_common (inode, raw_inode,0 ); -/* -* XXX: call with has_bmap = 0 is a workaround to avoid -* deadlock of bmap. This delays update of i_bmap to just -* before writing. -*/ +nilfs_write_inode_common (inode, raw_inode); + +if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) + raw_inode->i_device_code = +cpu_to_le64 (huge_encode_dev (inode->i_rdev));nilfs_ifile_unmap_inode (ifile, ino, ibh); }
fs/nilfs2/nilfs.h +2 -1
@@ -256,7 +256,8 @@ extern struct inode *nilfs_new_inode(struct inode *, umode_t);extern int nilfs_get_block (struct inode *,sector_t ,struct buffer_head *,int );extern void nilfs_set_inode_flags (struct inode *);extern int nilfs_read_inode_common (struct inode *,struct nilfs_inode *); -extern void nilfs_write_inode_common (struct inode *,struct nilfs_inode *,int ); +void nilfs_write_inode_common (struct inode *inode, +struct nilfs_inode *raw_inode);struct inode *nilfs_ilookup (struct super_block *sb,struct nilfs_root *root,unsigned long ino); struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root,
fs/nilfs2/segment.c +39 -8
71 lines not on this page · raw message
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 9/15 nilfs2: do not acquire rwsem in nilfs_bmap_write()
In reply to Ryusuke KonishiIt is now clear that nilfs_bmap_write() is only used to finalize logs written to disk. Concurrent bmap modification operations are not performed on bmaps in this context. Additionally, this function does not modify data used in read-only operations such as bmap lookups.
Therefore, there is no need to acquire bmap->b_sem in nilfs_bmap_write(), so delete it.
--- fs/nilfs2/bmap.c | 3 --- 1 file changed, 3 deletions(-)
fs/nilfs2/bmap.c +0 -3
@@ -548,13 +548,10 @@ int nilfs_bmap_read(struct nilfs_bmap *bmap, struct nilfs_inode *raw_inode)*/ void nilfs_bmap_write (struct nilfs_bmap *bmap,struct nilfs_inode *raw_inode) { -down_write (&bmap->b_sem);memcpy (raw_inode->i_bmap, bmap->b_u.u_data,NILFS_INODE_BMAP_SIZE *sizeof (__le64));if (bmap->b_inode->i_ino ==NILFS_DAT_INO ) bmap->b_last_allocated_ptr =NILFS_BMAP_NEW_PTR_INIT ; - -up_write (&bmap->b_sem); }void nilfs_bmap_init_gc (struct nilfs_bmap *bmap)
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 10/15 nilfs2: convert ifile to use kmap_local
In reply to Ryusuke KonishiConvert deprecated kmap() and kmap_atomic() to use kmap_local for the ifile metadata file used to manage disk inodes.
In some usages, calls to kmap_local and kunmap_local are split into different helpers, but those usages can be safely changed to local thread kmap.
--- fs/nilfs2/ifile.c | 4 ++-- fs/nilfs2/ifile.h | 7 +++---- fs/nilfs2/inode.c | 6 +++--- fs/nilfs2/segment.c | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-)
fs/nilfs2/ifile.c +2 -2
@@ -115,11 +115,11 @@ int nilfs_ifile_delete_inode(struct inode *ifile, ino_t ino)return ret; } - kaddr =kmap_atomic (req.pr_entry_bh->b_page); + kaddr =kmap_local_page (req.pr_entry_bh->b_page); raw_inode =nilfs_palloc_block_get_entry (ifile, req.pr_entry_nr, req.pr_entry_bh, kaddr); raw_inode->i_flags =0 ; -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (req.pr_entry_bh);brelse (req.pr_entry_bh);
fs/nilfs2/ifile.h +3 -4
@@ -21,15 +21,14 @@static inline struct nilfs_inode *nilfs_ifile_map_inode (struct inode *ifile,ino_t ino,struct buffer_head *ibh) { -void *kaddr =kmap (ibh->b_page); +void *kaddr =kmap_local_page (ibh->b_page);return nilfs_palloc_block_get_entry (ifile, ino, ibh, kaddr); } -static inline void nilfs_ifile_unmap_inode (struct inode *ifile,ino_t ino, -struct buffer_head *ibh) +static inline void nilfs_ifile_unmap_inode (struct nilfs_inode *raw_inode) { -kunmap (ibh->b_page); +kunmap_local (raw_inode); }int nilfs_ifile_create_inode (struct inode *,ino_t *,struct buffer_head **);
fs/nilfs2/inode.c +3 -3
@@ -520,7 +520,7 @@ static int __nilfs_read_inode(struct super_block *sb, inode, inode->i_mode, huge_decode_dev(le64_to_cpu(raw_inode->i_device_code))); } -nilfs_ifile_unmap_inode (root->ifile, ino, bh); +nilfs_ifile_unmap_inode (raw_inode);brelse (bh);up_read (&NILFS_MDT (nilfs->ns_dat)->mi_sem);nilfs_set_inode_flags (inode);
@@ -529,7 +529,7 @@ static int __nilfs_read_inode(struct super_block *sb,return 0 ; failed_unmap: -nilfs_ifile_unmap_inode (root->ifile, ino, bh); +nilfs_ifile_unmap_inode (raw_inode);brelse (bh); bad_inode:
@@ -814,7 +814,7 @@ void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh, int flags) raw_inode->i_device_code =cpu_to_le64 (huge_encode_dev (inode->i_rdev)); -nilfs_ifile_unmap_inode (ifile, ino, ibh); +nilfs_ifile_unmap_inode (raw_inode); }#define NILFS_MAX_TRUNCATE_BLOCKS 16384/* 64MB for 4KB block */
fs/nilfs2/segment.c +1 -1
@@ -966,7 +966,7 @@ static void nilfs_fill_in_file_bmap(struct inode *ifile, raw_inode =nilfs_ifile_map_inode (ifile, ii->vfs_inode.i_ino, ibh);nilfs_bmap_write (ii->i_bmap, raw_inode); -nilfs_ifile_unmap_inode (ifile, ii->vfs_inode.i_ino, ibh); +nilfs_ifile_unmap_inode (raw_inode); } }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 11/15 nilfs2: localize highmem mapping for checkpoint creation within cpfile
In reply to Ryusuke KonishiIn order to convert kmap() used in cpfile to kmap_local, first move the checkpoint creation routine, which is one of the places where kmap is used, to the cpfile side and make the page mapping local and temporary. And use kmap_local instead of kmap to access the checkpoint entry page (and header block page) when generating a checkpoint.
--- fs/nilfs2/cpfile.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ fs/nilfs2/cpfile.h | 1 + fs/nilfs2/segment.c | 31 ++----------------- 3 files changed, 77 insertions(+), 29 deletions(-)
fs/nilfs2/cpfile.c +74 -0
@@ -272,6 +272,80 @@ int nilfs_cpfile_get_checkpoint(struct inode *cpfile,return ret; } +/** +* nilfs_cpfile_create_checkpoint - create a checkpoint entry on cpfile +* @cpfile: checkpoint file inode +* @cno: number of checkpoint to set up +* +* This function creates a checkpoint with the number specified by @cno on +* cpfile. If the specified checkpoint entry already exists due to a past +* failure, it will be reused without returning an error. +* In either case, the buffer of the block containing the checkpoint entry +* and the cpfile inode are made dirty for inclusion in the write log. +* +* Return: 0 on success, or the following negative error code on failure. +* * %-ENOMEM - Insufficient memory available. +* * %-EIO - I/O error (including metadata corruption). +* * %-EROFS - Read only filesystem +*/ +int nilfs_cpfile_create_checkpoint (struct inode *cpfile,__u64 cno) +{ +struct buffer_head *header_bh, *cp_bh; +struct nilfs_cpfile_header *header; +struct nilfs_checkpoint *cp; +void *kaddr; +int ret; + +if (WARN_ON_ONCE (cno <1 )) +return -EIO ; + +down_write (&NILFS_MDT (cpfile)->mi_sem); + ret =nilfs_cpfile_get_header_block (cpfile, &header_bh); +if (unlikely (ret <0 )) { +if (ret == -ENOENT ) { +nilfs_error (cpfile->i_sb, +"checkpoint creation failed due to metadata corruption." ); + ret = -EIO ; + } + goto out_sem; + } + ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno,1 , &cp_bh); +if (unlikely (ret <0 )) + goto out_header; + + kaddr =kmap_local_page (cp_bh->b_page); + cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr); +if (nilfs_checkpoint_invalid (cp)) { +/* a newly-created checkpoint */ +nilfs_checkpoint_clear_invalid (cp); +if (!nilfs_cpfile_is_in_first (cpfile, cno)) +nilfs_cpfile_block_add_valid_checkpoints (cpfile, cp_bh, + kaddr,1 ); +kunmap_local (kaddr); + + kaddr =kmap_local_page (header_bh->b_page); + header =nilfs_cpfile_block_get_header (cpfile, header_bh, + kaddr); +le64_add_cpu (&header->ch_ncheckpoints,1 ); +kunmap_local (kaddr); +mark_buffer_dirty (header_bh); + }else { +kunmap_local (kaddr); + } + +/* Force the buffer and the inode to become dirty */ +mark_buffer_dirty (cp_bh); +brelse (cp_bh); +nilfs_mdt_mark_dirty (cpfile); + +out_header: +brelse (header_bh); + +out_sem: +up_write (&NILFS_MDT (cpfile)->mi_sem); +return ret; +} +/** * nilfs_cpfile_put_checkpoint - put a checkpoint * @cpfile: inode of checkpoint file
fs/nilfs2/cpfile.h +1 -0
@@ -19,6 +19,7 @@int nilfs_cpfile_get_checkpoint (struct inode *,__u64 ,int ,struct nilfs_checkpoint **,struct buffer_head **); +int nilfs_cpfile_create_checkpoint (struct inode *cpfile,__u64 cno);void nilfs_cpfile_put_checkpoint (struct inode *,__u64 ,struct buffer_head *);int nilfs_cpfile_delete_checkpoints (struct inode *,__u64 ,__u64 );int nilfs_cpfile_delete_checkpoint (struct inode *,__u64 );
fs/nilfs2/segment.c +2 -29
@@ -880,34 +880,6 @@ static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci)nilfs_mdt_clear_dirty (nilfs->ns_dat); } -static int nilfs_segctor_create_checkpoint (struct nilfs_sc_info *sci) -{ -struct the_nilfs *nilfs = sci->sc_super->s_fs_info; -struct buffer_head *bh_cp; -struct nilfs_checkpoint *raw_cp; -int err; - -/* XXX: this interface will be changed */ - err =nilfs_cpfile_get_checkpoint (nilfs->ns_cpfile, nilfs->ns_cno,1 , - &raw_cp, &bh_cp); -if (likely (!err)) { -/* -* The following code is duplicated with cpfile. But, it is -* needed to collect the checkpoint even if it was not newly -* created. -*/ -mark_buffer_dirty (bh_cp); -nilfs_mdt_mark_dirty (nilfs->ns_cpfile); -nilfs_cpfile_put_checkpoint ( - nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); - }else if (err == -EINVAL || err == -ENOENT ) { -nilfs_error (sci->sc_super, -"checkpoint creation failed due to metadata corruption." ); - err = -EIO ; - } -return err; -} -static int nilfs_segctor_fill_in_checkpoint (struct nilfs_sc_info *sci) {struct the_nilfs *nilfs = sci->sc_super->s_fs_info;
@@ -1261,7 +1233,8 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)break ;nilfs_sc_cstage_inc (sci);/* Creating a checkpoint */ - err =nilfs_segctor_create_checkpoint (sci); + err =nilfs_cpfile_create_checkpoint (nilfs->ns_cpfile, + nilfs->ns_cno);if (unlikely (err))break ; fallthrough;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 12/15 nilfs2: localize highmem mapping for checkpoint finalization within cpfile
In reply to Ryusuke KonishiMove the checkpoint finalization routine to the cpfile side, and make the page mapping local and temporary. And use kmap_local instead of kmap to access the checkpoint entry page when finalizing a checkpoint.
In this conversion, some of the information on the checkpoint entry being rewritten is passed through the arguments of the newly added method nilfs_cpfile_finalize_checkpoint().
--- fs/nilfs2/cpfile.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ fs/nilfs2/cpfile.h | 3 ++ fs/nilfs2/segment.c | 51 +++---------------------------- 3 files changed, 82 insertions(+), 46 deletions(-)
fs/nilfs2/cpfile.c +74 -0
@@ -363,6 +363,80 @@ void nilfs_cpfile_put_checkpoint(struct inode *cpfile, __u64 cno,brelse (bh); } +/** +* nilfs_cpfile_finalize_checkpoint - fill in a checkpoint entry in cpfile +* @cpfile: checkpoint file inode +* @cno: checkpoint number +* @root: nilfs root object +* @blkinc: number of blocks added by this checkpoint +* @ctime: checkpoint creation time +* @minor: minor checkpoint flag +* +* This function completes the checkpoint entry numbered by @cno in the +* cpfile with the data given by the arguments @root, @blkinc, @ctime, and +* @minor. +* +* Return: 0 on success, or the following negative error code on failure. +* * %-ENOMEM - Insufficient memory available. +* * %-EIO - I/O error (including metadata corruption). +*/ +int nilfs_cpfile_finalize_checkpoint (struct inode *cpfile,__u64 cno, +struct nilfs_root *root,__u64 blkinc, +time64_t ctime,bool minor) +{ +struct buffer_head *cp_bh; +struct nilfs_checkpoint *cp; +void *kaddr; +int ret; + +if (WARN_ON_ONCE (cno <1 )) +return -EIO ; + +down_write (&NILFS_MDT (cpfile)->mi_sem); + ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno,0 , &cp_bh); +if (unlikely (ret <0 )) { +if (ret == -ENOENT ) + goto error; + goto out_sem; + } + + kaddr =kmap_local_page (cp_bh->b_page); + cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr); +if (unlikely (nilfs_checkpoint_invalid (cp))) { +kunmap_local (kaddr); +brelse (cp_bh); + goto error; + } + + cp->cp_snapshot_list.ssl_next =0 ; + cp->cp_snapshot_list.ssl_prev =0 ; + cp->cp_inodes_count =cpu_to_le64 (atomic64_read (&root->inodes_count)); + cp->cp_blocks_count =cpu_to_le64 (atomic64_read (&root->blocks_count)); + cp->cp_nblk_inc =cpu_to_le64 (blkinc); + cp->cp_create =cpu_to_le64 (ctime); + cp->cp_cno =cpu_to_le64 (cno); + +if (minor) +nilfs_checkpoint_set_minor (cp); +else +nilfs_checkpoint_clear_minor (cp); + +nilfs_write_inode_common (root->ifile, &cp->cp_ifile_inode); +nilfs_bmap_write (NILFS_I (root->ifile)->i_bmap, &cp->cp_ifile_inode); + +kunmap_local (kaddr); +brelse (cp_bh); +out_sem: +up_write (&NILFS_MDT (cpfile)->mi_sem); +return ret; + +error: +nilfs_error (cpfile->i_sb, +"checkpoint finalization failed due to metadata corruption." ); + ret = -EIO ; + goto out_sem; +} +/** * nilfs_cpfile_delete_checkpoints - delete checkpoints * @cpfile: inode of checkpoint file
fs/nilfs2/cpfile.h +3 -0
@@ -21,6 +21,9 @@ int nilfs_cpfile_get_checkpoint(struct inode *, __u64, int, struct buffer_head **); int nilfs_cpfile_create_checkpoint(struct inode *cpfile, __u64 cno);void nilfs_cpfile_put_checkpoint (struct inode *,__u64 ,struct buffer_head *); +int nilfs_cpfile_finalize_checkpoint (struct inode *cpfile,__u64 cno, +struct nilfs_root *root,__u64 blkinc, +time64_t ctime,bool minor);int nilfs_cpfile_delete_checkpoints (struct inode *,__u64 ,__u64 );int nilfs_cpfile_delete_checkpoint (struct inode *,__u64 );int nilfs_cpfile_change_cpmode (struct inode *,__u64 ,int );
fs/nilfs2/segment.c +5 -46
63 lines not on this page · raw message
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 13/15 nilfs2: localize highmem mapping for checkpoint reading within cpfile
In reply to Ryusuke KonishiMove the code for reading from a checkpoint entry that is performed in nilfs_attach_checkpoint() to the cpfile side, and make the page mapping local and temporary. And use kmap_local instead of kmap to access the checkpoint entry page.
In order to load the ifile inode information included in the checkpoint entry within the inode lock section of nilfs_ifile_read(), the newly added checkpoint reading method nilfs_cpfile_read_checkpoint() is called indirectly via nilfs_ifile_read() instead of from nilfs_attach_checkpoint().
--- fs/nilfs2/cpfile.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ fs/nilfs2/cpfile.h | 2 ++ fs/nilfs2/ifile.c | 17 ++++++++---- fs/nilfs2/ifile.h | 3 +- fs/nilfs2/super.c | 31 ++++----------------- 5 files changed, 87 insertions(+), 34 deletions(-)
fs/nilfs2/cpfile.c +68 -0
@@ -186,6 +186,74 @@ static inline int nilfs_cpfile_delete_checkpoint_block(struct inode *cpfile, nilfs_cpfile_get_blkoff(cpfile, cno)); } +/** +* nilfs_cpfile_read_checkpoint - read a checkpoint entry in cpfile +* @cpfile: checkpoint file inode +* @cno: number of checkpoint entry to read +* @root: nilfs root object +* @ifile: ifile's inode to read and attach to @root +* +* This function imports checkpoint information from the checkpoint file and +* stores it to the inode file given by @ifile and the nilfs root object +* given by @root. +* +* Return: 0 on success, or the following negative error code on failure. +* * %-EINVAL - Invalid checkpoint. +* * %-ENOMEM - Insufficient memory available. +* * %-EIO - I/O error (including metadata corruption). +*/ +int nilfs_cpfile_read_checkpoint (struct inode *cpfile,__u64 cno, +struct nilfs_root *root,struct inode *ifile) +{ +struct buffer_head *cp_bh; +struct nilfs_checkpoint *cp; +void *kaddr; +int ret; + +if (cno <1 || cno >nilfs_mdt_cno (cpfile)) +return -EINVAL ; + +down_read (&NILFS_MDT (cpfile)->mi_sem); + ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno,0 , &cp_bh); +if (unlikely (ret <0 )) { +if (ret == -ENOENT ) + ret = -EINVAL ; + goto out_sem; + } + + kaddr =kmap_local_page (cp_bh->b_page); + cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr); +if (nilfs_checkpoint_invalid (cp)) { + ret = -EINVAL ; + goto put_cp; + } + + ret =nilfs_read_inode_common (ifile, &cp->cp_ifile_inode); +if (unlikely (ret)) { +/* +* Since this inode is on a checkpoint entry, treat errors +* as metadata corruption. +*/ +nilfs_err (cpfile->i_sb, +"ifile inode (checkpoint number=%llu) corrupted" , + (unsigned long long )cno); + ret = -EIO ; + goto put_cp; + } + +/* Configure the nilfs root object */ +atomic64_set (&root->inodes_count,le64_to_cpu (cp->cp_inodes_count)); +atomic64_set (&root->blocks_count,le64_to_cpu (cp->cp_blocks_count)); + root->ifile = ifile; + +put_cp: +kunmap_local (kaddr); +brelse (cp_bh); +out_sem: +up_read (&NILFS_MDT (cpfile)->mi_sem); +return ret; +} +/** * nilfs_cpfile_get_checkpoint - get a checkpoint * @cpfile: inode of checkpoint file
fs/nilfs2/cpfile.h +2 -0
@@ -19,6 +19,8 @@int nilfs_cpfile_get_checkpoint (struct inode *,__u64 ,int ,struct nilfs_checkpoint **,struct buffer_head **); +int nilfs_cpfile_read_checkpoint (struct inode *cpfile,__u64 cno, +struct nilfs_root *root,struct inode *ifile);int nilfs_cpfile_create_checkpoint (struct inode *cpfile,__u64 cno);void nilfs_cpfile_put_checkpoint (struct inode *,__u64 ,struct buffer_head *); int nilfs_cpfile_finalize_checkpoint(struct inode *cpfile, __u64 cno,
fs/nilfs2/ifile.c +11 -6
@@ -15,6 +15,7 @@#include "mdt.h" #include "alloc.h" #include "ifile.h" +#include "cpfile.h" /** * struct nilfs_ifile_info - on-memory private data of ifile
@@ -173,14 +174,18 @@ int nilfs_ifile_count_free_inodes(struct inode *ifile,* nilfs_ifile_read - read or get ifile inode * @sb: super block instance * @root: root object +* @cno: number of checkpoint entry to read * @inode_size: size of an inode -* @raw_inode: on-disk ifile inode -* @inodep: buffer to store the inode +* +* Return: 0 on success, or the following negative error code on failure. +* * %-EINVAL - Invalid checkpoint. +* * %-ENOMEM - Insufficient memory available. +* * %-EIO - I/O error (including metadata corruption). */ int nilfs_ifile_read (struct super_block *sb,struct nilfs_root *root, -size_t inode_size,struct nilfs_inode *raw_inode, -struct inode **inodep) +__u64 cno,size_t inode_size) { +struct the_nilfs *nilfs;struct inode *ifile;int err;
@@ -201,13 +206,13 @@ int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root,nilfs_palloc_setup_cache (ifile, &NILFS_IFILE_I (ifile)->palloc_cache); - err =nilfs_read_inode_common (ifile, raw_inode); + nilfs = sb->s_fs_info; + err =nilfs_cpfile_read_checkpoint (nilfs->ns_cpfile, cno, root, ifile);if (err) goto failed;unlock_new_inode (ifile); out: - *inodep = ifile;return 0 ; failed:iget_failed (ifile);
fs/nilfs2/ifile.h +1 -2
@@ -38,7 +38,6 @@ int nilfs_ifile_get_inode_block(struct inode *, ino_t, struct buffer_head **);int nilfs_ifile_count_free_inodes (struct inode *,u64 *,u64 *);int nilfs_ifile_read (struct super_block *sb,struct nilfs_root *root, -size_t inode_size,struct nilfs_inode *raw_inode, -struct inode **inodep); +__u64 cno,size_t inode_size);#endif /* _NILFS_IFILE_H */
fs/nilfs2/super.c +5 -26
@@ -544,8 +544,6 @@ int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, {struct the_nilfs *nilfs = sb->s_fs_info;struct nilfs_root *root; -struct nilfs_checkpoint *raw_cp; -struct buffer_head *bh_cp;int err = -ENOMEM ; root = nilfs_find_or_create_root(
@@ -557,38 +555,19 @@ int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, goto reuse;/* already attached checkpoint */ down_read (&nilfs->ns_segctor_sem); - err =nilfs_cpfile_get_checkpoint (nilfs->ns_cpfile, cno,0 , &raw_cp, - &bh_cp); + err =nilfs_ifile_read (sb, root, cno, nilfs->ns_inode_size);up_read (&nilfs->ns_segctor_sem); -if (unlikely (err)) { -if (err == -ENOENT || err == -EINVAL ) { -nilfs_err (sb, -"Invalid checkpoint (checkpoint number=%llu)" , - (unsigned long long )cno); - err = -EINVAL ; - } +if (unlikely (err)) goto failed; - } - - err =nilfs_ifile_read (sb, root, nilfs->ns_inode_size, - &raw_cp->cp_ifile_inode, &root->ifile); -if (err) - goto failed_bh; - -atomic64_set (&root->inodes_count, -le64_to_cpu (raw_cp->cp_inodes_count)); -atomic64_set (&root->blocks_count, -le64_to_cpu (raw_cp->cp_blocks_count)); - -nilfs_cpfile_put_checkpoint (nilfs->ns_cpfile, cno, bh_cp); reuse: *rootp = root;return 0 ; - failed_bh: -nilfs_cpfile_put_checkpoint (nilfs->ns_cpfile, cno, bh_cp); failed: +if (err == -EINVAL ) +nilfs_err (sb,"Invalid checkpoint (checkpoint number=%llu)" , + (unsigned long long )cno);nilfs_put_root (root);return err;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 14/15 nilfs2: remove nilfs_cpfile_{get,put}_checkpoint()
In reply to Ryusuke KonishiAll calls to nilfs_cpfile_get_checkpoint() and nilfs_cpfile_put_checkpoint() that call kmap() and kunmap() separately are now gone, so remove these methods.
--- fs/nilfs2/cpfile.c | 103 --------------------------------------------- fs/nilfs2/cpfile.h | 4 -- 2 files changed, 107 deletions(-)
fs/nilfs2/cpfile.c +0 -103
@@ -254,92 +254,6 @@ int nilfs_cpfile_read_checkpoint(struct inode *cpfile, __u64 cno,return ret; } -/** -* nilfs_cpfile_get_checkpoint - get a checkpoint -* @cpfile: inode of checkpoint file -* @cno: checkpoint number -* @create: create flag -* @cpp: pointer to a checkpoint -* @bhp: pointer to a buffer head -* -* Description: nilfs_cpfile_get_checkpoint() acquires the checkpoint -* specified by @cno. A new checkpoint will be created if @cno is the current -* checkpoint number and @create is nonzero. -* -* Return Value: On success, 0 is returned, and the checkpoint and the -* buffer head of the buffer on which the checkpoint is located are stored in -* the place pointed by @cpp and @bhp, respectively. On error, one of the -* following negative error codes is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. -* -* %-ENOENT - No such checkpoint. -* -* %-EINVAL - invalid checkpoint. -*/ -int nilfs_cpfile_get_checkpoint (struct inode *cpfile, -__u64 cno, -int create, -struct nilfs_checkpoint **cpp, -struct buffer_head **bhp) -{ -struct buffer_head *header_bh, *cp_bh; -struct nilfs_cpfile_header *header; -struct nilfs_checkpoint *cp; -void *kaddr; -int ret; - -if (unlikely (cno <1 || cno >nilfs_mdt_cno (cpfile) || - (cno <nilfs_mdt_cno (cpfile) && create))) -return -EINVAL ; - -down_write (&NILFS_MDT (cpfile)->mi_sem); - - ret =nilfs_cpfile_get_header_block (cpfile, &header_bh); -if (ret <0 ) - goto out_sem; - ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno, create, &cp_bh); -if (ret <0 ) - goto out_header; - kaddr =kmap (cp_bh->b_page); - cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr); -if (nilfs_checkpoint_invalid (cp)) { -if (!create) { -kunmap (cp_bh->b_page); -brelse (cp_bh); - ret = -ENOENT ; - goto out_header; - } -/* a newly-created checkpoint */ -nilfs_checkpoint_clear_invalid (cp); -if (!nilfs_cpfile_is_in_first (cpfile, cno)) -nilfs_cpfile_block_add_valid_checkpoints (cpfile, cp_bh, - kaddr,1 ); -mark_buffer_dirty (cp_bh); - - kaddr =kmap_atomic (header_bh->b_page); - header =nilfs_cpfile_block_get_header (cpfile, header_bh, - kaddr); -le64_add_cpu (&header->ch_ncheckpoints,1 ); -kunmap_atomic (kaddr); -mark_buffer_dirty (header_bh); -nilfs_mdt_mark_dirty (cpfile); - } - -if (cpp !=NULL ) - *cpp = cp; - *bhp = cp_bh; - - out_header: -brelse (header_bh); - - out_sem: -up_write (&NILFS_MDT (cpfile)->mi_sem); -return ret; -} -/** * nilfs_cpfile_create_checkpoint - create a checkpoint entry on cpfile * @cpfile: checkpoint file inode
@@ -414,23 +328,6 @@ int nilfs_cpfile_create_checkpoint(struct inode *cpfile, __u64 cno)return ret; } -/** -* nilfs_cpfile_put_checkpoint - put a checkpoint -* @cpfile: inode of checkpoint file -* @cno: checkpoint number -* @bh: buffer head -* -* Description: nilfs_cpfile_put_checkpoint() releases the checkpoint -* specified by @cno. @bh must be the buffer head which has been returned by -* a previous call to nilfs_cpfile_get_checkpoint() with @cno. -*/ -void nilfs_cpfile_put_checkpoint (struct inode *cpfile,__u64 cno, -struct buffer_head *bh) -{ -kunmap (bh->b_page); -brelse (bh); -} -/** * nilfs_cpfile_finalize_checkpoint - fill in a checkpoint entry in cpfile * @cpfile: checkpoint file inode
fs/nilfs2/cpfile.h +0 -4
@@ -16,13 +16,9 @@#include <linux/nilfs2_ondisk.h> /* nilfs_inode, nilfs_checkpoint */ -int nilfs_cpfile_get_checkpoint (struct inode *,__u64 ,int , -struct nilfs_checkpoint **, -struct buffer_head **);int nilfs_cpfile_read_checkpoint (struct inode *cpfile,__u64 cno,struct nilfs_root *root,struct inode *ifile);int nilfs_cpfile_create_checkpoint (struct inode *cpfile,__u64 cno); -void nilfs_cpfile_put_checkpoint (struct inode *,__u64 ,struct buffer_head *);int nilfs_cpfile_finalize_checkpoint (struct inode *cpfile,__u64 cno,struct nilfs_root *root,__u64 blkinc,time64_t ctime,bool minor);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 15/15 nilfs2: convert cpfile to use kmap_local
In reply to Ryusuke KonishiConvert all remaining usages of kmap_atomic in cpfile to kmap_local.
--- fs/nilfs2/cpfile.c | 90 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-)
fs/nilfs2/cpfile.c +45 -45
@@ -460,7 +460,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,continue ; } - kaddr =kmap_atomic (cp_bh->b_page); + kaddr =kmap_local_page (cp_bh->b_page); cp =nilfs_cpfile_block_get_checkpoint ( cpfile, cno, cp_bh, kaddr); nicps =0 ;
@@ -482,7 +482,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, cpfile, cp_bh, kaddr, nicps);if (count ==0 ) {/* make hole */ -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (cp_bh); ret = nilfs_cpfile_delete_checkpoint_block(
@@ -497,18 +497,18 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile, } } -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (cp_bh); }if (tnicps >0 ) { - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header =nilfs_cpfile_block_get_header (cpfile, header_bh, kaddr);le64_add_cpu (&header->ch_ncheckpoints, -(u64 )tnicps);mark_buffer_dirty (header_bh);nilfs_mdt_mark_dirty (cpfile); -kunmap_atomic (kaddr); +kunmap_local (kaddr); }brelse (header_bh);
@@ -560,7 +560,7 @@ static ssize_t nilfs_cpfile_do_get_cpinfo(struct inode *cpfile, __u64 *cnop, } ncps =nilfs_cpfile_checkpoints_in_block (cpfile, cno, cur_cno); - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, bh, kaddr);for (i =0 ; i < ncps && n < nci; i++, cp = (void *)cp + cpsz) {if (!nilfs_checkpoint_invalid (cp)) {
@@ -570,7 +570,7 @@ static ssize_t nilfs_cpfile_do_get_cpinfo(struct inode *cpfile, __u64 *cnop, n++; } } -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh); }
@@ -604,10 +604,10 @@ static ssize_t nilfs_cpfile_do_get_ssinfo(struct inode *cpfile, __u64 *cnop, ret =nilfs_cpfile_get_header_block (cpfile, &bh);if (ret <0 ) goto out; - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); header =nilfs_cpfile_block_get_header (cpfile, bh, kaddr); curr =le64_to_cpu (header->ch_snapshot_list.ssl_next); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh);if (curr ==0 ) { ret =0 ;
@@ -625,7 +625,7 @@ static ssize_t nilfs_cpfile_do_get_ssinfo(struct inode *cpfile, __u64 *cnop, ret =0 ;/* No snapshots (started from a hole block) */ goto out; } - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page);while (n < nci) { cp =nilfs_cpfile_block_get_checkpoint (cpfile, curr, bh, kaddr); curr = ~(__u64 )0 ;/* Terminator */
@@ -641,7 +641,7 @@ static ssize_t nilfs_cpfile_do_get_ssinfo(struct inode *cpfile, __u64 *cnop, next_blkoff =nilfs_cpfile_get_blkoff (cpfile, next);if (curr_blkoff != next_blkoff) { -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh); ret =nilfs_cpfile_get_checkpoint_block (cpfile, next,0 , &bh);
@@ -649,12 +649,12 @@ static ssize_t nilfs_cpfile_do_get_ssinfo(struct inode *cpfile, __u64 *cnop,WARN_ON (ret == -ENOENT ); goto out; } - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); } curr = next; curr_blkoff = next_blkoff; } -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh); *cnop = curr; ret = n;
@@ -763,24 +763,24 @@ static int nilfs_cpfile_set_snapshot(struct inode *cpfile, __u64 cno) ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno,0 , &cp_bh);if (ret <0 ) goto out_sem; - kaddr =kmap_atomic (cp_bh->b_page); + kaddr =kmap_local_page (cp_bh->b_page); cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr);if (nilfs_checkpoint_invalid (cp)) { ret = -ENOENT ; -kunmap_atomic (kaddr); +kunmap_local (kaddr); goto out_cp; }if (nilfs_checkpoint_snapshot (cp)) { ret =0 ; -kunmap_atomic (kaddr); +kunmap_local (kaddr); goto out_cp; } -kunmap_atomic (kaddr); +kunmap_local (kaddr); ret =nilfs_cpfile_get_header_block (cpfile, &header_bh);if (ret <0 ) goto out_cp; - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header =nilfs_cpfile_block_get_header (cpfile, header_bh, kaddr); list = &header->ch_snapshot_list; curr_bh = header_bh;
@@ -792,13 +792,13 @@ static int nilfs_cpfile_set_snapshot(struct inode *cpfile, __u64 cno) prev_blkoff =nilfs_cpfile_get_blkoff (cpfile, prev); curr = prev;if (curr_blkoff != prev_blkoff) { -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (curr_bh); ret =nilfs_cpfile_get_checkpoint_block (cpfile, curr,0 , &curr_bh);if (ret <0 ) goto out_header; - kaddr =kmap_atomic (curr_bh->b_page); + kaddr =kmap_local_page (curr_bh->b_page); } curr_blkoff = prev_blkoff; cp = nilfs_cpfile_block_get_checkpoint(
@@ -806,7 +806,7 @@ static int nilfs_cpfile_set_snapshot(struct inode *cpfile, __u64 cno) list = &cp->cp_snapshot_list; prev =le64_to_cpu (list->ssl_prev); } -kunmap_atomic (kaddr); +kunmap_local (kaddr);if (prev !=0 ) { ret = nilfs_cpfile_get_checkpoint_block(cpfile, prev, 0,
@@ -818,29 +818,29 @@ static int nilfs_cpfile_set_snapshot(struct inode *cpfile, __u64 cno)get_bh (prev_bh); } - kaddr =kmap_atomic (curr_bh->b_page); + kaddr =kmap_local_page (curr_bh->b_page); list =nilfs_cpfile_block_get_snapshot_list ( cpfile, curr, curr_bh, kaddr); list->ssl_prev =cpu_to_le64 (cno); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (cp_bh->b_page); + kaddr =kmap_local_page (cp_bh->b_page); cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr); cp->cp_snapshot_list.ssl_next =cpu_to_le64 (curr); cp->cp_snapshot_list.ssl_prev =cpu_to_le64 (prev);nilfs_checkpoint_set_snapshot (cp); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (prev_bh->b_page); + kaddr =kmap_local_page (prev_bh->b_page); list =nilfs_cpfile_block_get_snapshot_list ( cpfile, prev, prev_bh, kaddr); list->ssl_next =cpu_to_le64 (cno); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header =nilfs_cpfile_block_get_header (cpfile, header_bh, kaddr);le64_add_cpu (&header->ch_nsnapshots,1 ); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (prev_bh);mark_buffer_dirty (curr_bh);
@@ -881,23 +881,23 @@ static int nilfs_cpfile_clear_snapshot(struct inode *cpfile, __u64 cno) ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno,0 , &cp_bh);if (ret <0 ) goto out_sem; - kaddr =kmap_atomic (cp_bh->b_page); + kaddr =kmap_local_page (cp_bh->b_page); cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr);if (nilfs_checkpoint_invalid (cp)) { ret = -ENOENT ; -kunmap_atomic (kaddr); +kunmap_local (kaddr); goto out_cp; }if (!nilfs_checkpoint_snapshot (cp)) { ret =0 ; -kunmap_atomic (kaddr); +kunmap_local (kaddr); goto out_cp; } list = &cp->cp_snapshot_list; next =le64_to_cpu (list->ssl_next); prev =le64_to_cpu (list->ssl_prev); -kunmap_atomic (kaddr); +kunmap_local (kaddr); ret =nilfs_cpfile_get_header_block (cpfile, &header_bh);if (ret <0 )
@@ -921,29 +921,29 @@ static int nilfs_cpfile_clear_snapshot(struct inode *cpfile, __u64 cno)get_bh (prev_bh); } - kaddr =kmap_atomic (next_bh->b_page); + kaddr =kmap_local_page (next_bh->b_page); list =nilfs_cpfile_block_get_snapshot_list ( cpfile, next, next_bh, kaddr); list->ssl_prev =cpu_to_le64 (prev); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (prev_bh->b_page); + kaddr =kmap_local_page (prev_bh->b_page); list =nilfs_cpfile_block_get_snapshot_list ( cpfile, prev, prev_bh, kaddr); list->ssl_next =cpu_to_le64 (next); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (cp_bh->b_page); + kaddr =kmap_local_page (cp_bh->b_page); cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, cp_bh, kaddr); cp->cp_snapshot_list.ssl_next =cpu_to_le64 (0 ); cp->cp_snapshot_list.ssl_prev =cpu_to_le64 (0 );nilfs_checkpoint_clear_snapshot (cp); -kunmap_atomic (kaddr); +kunmap_local (kaddr); - kaddr =kmap_atomic (header_bh->b_page); + kaddr =kmap_local_page (header_bh->b_page); header =nilfs_cpfile_block_get_header (cpfile, header_bh, kaddr);le64_add_cpu (&header->ch_nsnapshots,-1 ); -kunmap_atomic (kaddr); +kunmap_local (kaddr);mark_buffer_dirty (next_bh);mark_buffer_dirty (prev_bh);
@@ -1002,13 +1002,13 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno) ret =nilfs_cpfile_get_checkpoint_block (cpfile, cno,0 , &bh);if (ret <0 ) goto out; - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); cp =nilfs_cpfile_block_get_checkpoint (cpfile, cno, bh, kaddr);if (nilfs_checkpoint_invalid (cp)) ret = -ENOENT ;else ret =nilfs_checkpoint_snapshot (cp); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh); out:
@@ -1085,12 +1085,12 @@ int nilfs_cpfile_get_stat(struct inode *cpfile, struct nilfs_cpstat *cpstat) ret =nilfs_cpfile_get_header_block (cpfile, &bh);if (ret <0 ) goto out_sem; - kaddr =kmap_atomic (bh->b_page); + kaddr =kmap_local_page (bh->b_page); header =nilfs_cpfile_block_get_header (cpfile, bh, kaddr); cpstat->cs_cno =nilfs_mdt_cno (cpfile); cpstat->cs_ncps =le64_to_cpu (header->ch_ncheckpoints); cpstat->cs_nsss =le64_to_cpu (header->ch_nsnapshots); -kunmap_atomic (kaddr); +kunmap_local (kaddr);brelse (bh); out_sem:
Signature · 1 line
2.34.1