Lines Matching +full:block +full:- +full:number

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
24 * struct nilfs_dat_info - on-memory private data of DAT file
25 * @mi: on-memory private data of metadata file
45 ret = nilfs_palloc_get_entry_block(dat, req->pr_entry_nr, in nilfs_dat_prepare_entry()
46 create, &req->pr_entry_bh); in nilfs_dat_prepare_entry()
47 if (unlikely(ret == -ENOENT)) { in nilfs_dat_prepare_entry()
48 nilfs_err(dat->i_sb, in nilfs_dat_prepare_entry()
49 "DAT doesn't have a block to manage vblocknr = %llu", in nilfs_dat_prepare_entry()
50 (unsigned long long)req->pr_entry_nr); in nilfs_dat_prepare_entry()
52 * Return internal code -EINVAL to notify bmap layer of in nilfs_dat_prepare_entry()
55 ret = -EINVAL; in nilfs_dat_prepare_entry()
63 mark_buffer_dirty(req->pr_entry_bh); in nilfs_dat_commit_entry()
65 brelse(req->pr_entry_bh); in nilfs_dat_commit_entry()
71 brelse(req->pr_entry_bh); in nilfs_dat_abort_entry()
94 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_alloc()
95 req->pr_entry_bh); in nilfs_dat_commit_alloc()
96 entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset); in nilfs_dat_commit_alloc()
97 entry->de_start = cpu_to_le64(NILFS_CNO_MIN); in nilfs_dat_commit_alloc()
98 entry->de_end = cpu_to_le64(NILFS_CNO_MAX); in nilfs_dat_commit_alloc()
99 entry->de_blocknr = cpu_to_le64(0); in nilfs_dat_commit_alloc()
118 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_free()
119 req->pr_entry_bh); in nilfs_dat_commit_free()
120 entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset); in nilfs_dat_commit_free()
121 entry->de_start = cpu_to_le64(NILFS_CNO_MIN); in nilfs_dat_commit_free()
122 entry->de_end = cpu_to_le64(NILFS_CNO_MIN); in nilfs_dat_commit_free()
123 entry->de_blocknr = cpu_to_le64(0); in nilfs_dat_commit_free()
128 if (unlikely(req->pr_desc_bh == NULL || req->pr_bitmap_bh == NULL)) { in nilfs_dat_commit_free()
129 nilfs_error(dat->i_sb, in nilfs_dat_commit_free()
131 (unsigned long long)req->pr_entry_nr); in nilfs_dat_commit_free()
148 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_start()
149 req->pr_entry_bh); in nilfs_dat_commit_start()
150 entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset); in nilfs_dat_commit_start()
151 entry->de_start = cpu_to_le64(nilfs_mdt_cno(dat)); in nilfs_dat_commit_start()
152 entry->de_blocknr = cpu_to_le64(blocknr); in nilfs_dat_commit_start()
170 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_prepare_end()
171 req->pr_entry_bh); in nilfs_dat_prepare_end()
172 entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset); in nilfs_dat_prepare_end()
173 start = le64_to_cpu(entry->de_start); in nilfs_dat_prepare_end()
174 blocknr = le64_to_cpu(entry->de_blocknr); in nilfs_dat_prepare_end()
185 nilfs_err(dat->i_sb, in nilfs_dat_prepare_end()
187 (unsigned long long)req->pr_entry_nr, in nilfs_dat_prepare_end()
191 return -EINVAL; in nilfs_dat_prepare_end()
205 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_commit_end()
206 req->pr_entry_bh); in nilfs_dat_commit_end()
207 entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset); in nilfs_dat_commit_end()
208 end = start = le64_to_cpu(entry->de_start); in nilfs_dat_commit_end()
213 entry->de_end = cpu_to_le64(end); in nilfs_dat_commit_end()
214 blocknr = le64_to_cpu(entry->de_blocknr); in nilfs_dat_commit_end()
230 offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr, in nilfs_dat_abort_end()
231 req->pr_entry_bh); in nilfs_dat_abort_end()
232 entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset); in nilfs_dat_abort_end()
233 start = le64_to_cpu(entry->de_start); in nilfs_dat_abort_end()
234 blocknr = le64_to_cpu(entry->de_blocknr); in nilfs_dat_abort_end()
274 * nilfs_dat_mark_dirty - mark the DAT block buffer containing the specified
275 * virtual block address entry as dirty
277 * @vblocknr: virtual block number
281 * * %-EINVAL - Invalid DAT entry (internal code).
282 * * %-EIO - I/O error (including metadata corruption).
283 * * %-ENOMEM - Insufficient memory available.
298 * nilfs_dat_freev - free virtual block numbers
300 * @vblocknrs: array of virtual block numbers
301 * @nitems: number of virtual block numbers
303 * Description: nilfs_dat_freev() frees the virtual block numbers specified by
308 * * %-EIO - I/O error (including metadata corruption).
309 * * %-ENOENT - The virtual block number have not been allocated.
310 * * %-ENOMEM - Insufficient memory available.
318 * nilfs_dat_move - change a block number
320 * @vblocknr: virtual block number
321 * @blocknr: block number
323 * Description: nilfs_dat_move() changes the block number associated with
328 * * %-EIO - I/O error (including metadata corruption).
329 * * %-ENOMEM - Insufficient memory available.
343 * The given disk block number (blocknr) is not yet written to in nilfs_dat_move()
347 * uncommitted block number, this makes a copy of the entry in nilfs_dat_move()
359 entry = kmap_local_folio(entry_bh->b_folio, offset); in nilfs_dat_move()
360 if (unlikely(entry->de_blocknr == cpu_to_le64(0))) { in nilfs_dat_move()
361 nilfs_crit(dat->i_sb, in nilfs_dat_move()
364 (unsigned long long)le64_to_cpu(entry->de_start), in nilfs_dat_move()
365 (unsigned long long)le64_to_cpu(entry->de_end)); in nilfs_dat_move()
368 return -EINVAL; in nilfs_dat_move()
371 entry->de_blocknr = cpu_to_le64(blocknr); in nilfs_dat_move()
383 * nilfs_dat_translate - translate a virtual block number to a block number
385 * @vblocknr: virtual block number
386 * @blocknrp: pointer to a block number
388 * Description: nilfs_dat_translate() maps the virtual block number @vblocknr
389 * to the corresponding block number. The block number associated with
394 * * %-EIO - I/O error (including metadata corruption).
395 * * %-ENOENT - A block number associated with @vblocknr does not exist.
396 * * %-ENOMEM - Insufficient memory available.
420 entry = kmap_local_folio(entry_bh->b_folio, offset); in nilfs_dat_translate()
421 blocknr = le64_to_cpu(entry->de_blocknr); in nilfs_dat_translate()
423 ret = -ENOENT; in nilfs_dat_translate()
442 unsigned long entries_per_block = NILFS_MDT(dat)->mi_entries_per_block; in nilfs_dat_get_vinfo()
443 unsigned int entry_size = NILFS_MDT(dat)->mi_entry_size; in nilfs_dat_get_vinfo()
447 ret = nilfs_palloc_get_entry_block(dat, vinfo->vi_vblocknr, in nilfs_dat_get_vinfo()
452 first = vinfo->vi_vblocknr; in nilfs_dat_get_vinfo()
455 /* first virtual block number in this block */ in nilfs_dat_get_vinfo()
457 last = first + entries_per_block - 1; in nilfs_dat_get_vinfo()
458 /* last virtual block number in this block */ in nilfs_dat_get_vinfo()
461 first_entry = kmap_local_folio(entry_bh->b_folio, offset); in nilfs_dat_get_vinfo()
463 j < nvi && vinfo->vi_vblocknr >= first && in nilfs_dat_get_vinfo()
464 vinfo->vi_vblocknr <= last; in nilfs_dat_get_vinfo()
467 (vinfo->vi_vblocknr - first) * entry_size; in nilfs_dat_get_vinfo()
468 vinfo->vi_start = le64_to_cpu(entry->de_start); in nilfs_dat_get_vinfo()
469 vinfo->vi_end = le64_to_cpu(entry->de_end); in nilfs_dat_get_vinfo()
470 vinfo->vi_blocknr = le64_to_cpu(entry->de_blocknr); in nilfs_dat_get_vinfo()
480 * nilfs_dat_read - read or get dat inode
481 * @sb: super block instance
483 * @raw_inode: on-disk dat inode
496 if (entry_size > sb->s_blocksize) { in nilfs_dat_read()
499 return -EINVAL; in nilfs_dat_read()
503 return -EINVAL; in nilfs_dat_read()
508 return -ENOMEM; in nilfs_dat_read()
509 if (!(dat->i_state & I_NEW)) in nilfs_dat_read()
521 lockdep_set_class(&di->mi.mi_sem, &dat_lock_key); in nilfs_dat_read()
522 nilfs_palloc_setup_cache(dat, &di->palloc_cache); in nilfs_dat_read()
523 err = nilfs_mdt_setup_shadow_map(dat, &di->shadow); in nilfs_dat_read()