/** * nilfs_dat_translate - translate a virtual block number to a block number * @dat: DAT file inode * @vblocknr: virtual block number * @blocknrp: pointer to a block number * * Description: nilfs_dat_translate() maps the virtual block number @vblocknr * to the corresponding block number. * * Return Value: On success, 0 is returned and the block number associated * with @vblocknr is stored in the place pointed by @blocknrp. On error, one * of the following negative error codes is returned. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient amount of memory available. * * %-ENOENT - A block number associated with @vblocknr does not exist. */ int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp) { struct buffer_head *entry_bh, *bh; struct nilfs_dat_entry *entry; sector_t blocknr; void *kaddr; int ret; ret = nilfs_palloc_get_entry_block(dat, vblocknr, 0, &entry_bh); if (ret < 0) return ret; if (!nilfs_doing_gc() && buffer_nilfs_redirected(entry_bh)) { bh = nilfs_mdt_get_frozen_buffer(dat, entry_bh); if (bh) { WARN_ON(!buffer_uptodate(bh)); brelse(entry_bh); entry_bh = bh; } } kaddr = kmap_atomic(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) { ret = -ENOENT; goto out; } *blocknrp = blocknr; out: kunmap_atomic(kaddr); brelse(entry_bh); return ret; }
static int snprint_bh_state(char *b, int size, struct buffer_head *bh) { int len = 0, n = 0; TEST_BH_STATE(bh, uptodate, Uptodate, b, size, n, len); TEST_BH_STATE(bh, dirty, Dirty, b, size, n, len); TEST_BH_STATE(bh, locked, Locked, b, size, n, len); TEST_BH_STATE(bh, req, Req, b, size, n, len); TEST_BH_STATE(bh, mapped, Mapped, b, size, n, len); TEST_BH_STATE(bh, new, New, b, size, n, len); TEST_BH_STATE(bh, async_read, ARead, b, size, n, len); TEST_BH_STATE(bh, async_write, AWrite, b, size, n, len); TEST_BH_STATE(bh, delay, Delay, b, size, n, len); TEST_BH_STATE(bh, boundary, Boundary, b, size, n, len); TEST_BH_STATE(bh, write_io_error, WriteIOErr, b, size, n, len); TEST_BH_STATE(bh, ordered, Ordered, b, size, n, len); TEST_BH_STATE(bh, eopnotsupp, ENOTSUPP, b, size, n, len); /* nilfs private */ TEST_BH_STATE(bh, nilfs_allocated, Allocated, b, size, n, len); TEST_BH_STATE(bh, nilfs_node, Node, b, size, n, len); TEST_BH_STATE(bh, nilfs_volatile, Volatile, b, size, n, len); snprint_flag(b, size, nilfs_doing_gc(), DoingGC, n, len); return len; }