Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c7cb99a authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2: (22 commits)
  nilfs2: support contiguous lookup of blocks
  nilfs2: add sync_page method to page caches of meta data
  nilfs2: use device's backing_dev_info for btree node caches
  nilfs2: return EBUSY against delete request on snapshot
  nilfs2: modify list of unsupported features in caveats
  nilfs2: enable sync_page method
  nilfs2: set bio unplug flag for the last bio in segment
  nilfs2: allow future expansion of metadata read out via get info ioctl
  NILFS2: Pagecache usage optimization on NILFS2
  nilfs2: remove nilfs_btree_operations from btree mapping
  nilfs2: remove nilfs_direct_operations from direct mapping
  nilfs2: remove bmap pointer operations
  nilfs2: remove useless b_low and b_high fields from nilfs_bmap struct
  nilfs2: remove pointless NULL check of bpop_commit_alloc_ptr function
  nilfs2: move get block functions in bmap.c into btree codes
  nilfs2: remove nilfs_bmap_delete_block
  nilfs2: remove nilfs_bmap_put_block
  nilfs2: remove header file for segment list operations
  nilfs2: eliminate removal list of segments
  nilfs2: add sufile function that can modify multiple segment usages
  ...
parents 0a8eba9b c3a7abf0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -39,9 +39,8 @@ Features which NILFS2 does not support yet:
	- extended attributes
	- POSIX ACLs
	- quotas
	- writable snapshots
	- remote backup (CDP)
	- data integrity
	- fsck
	- resize
	- defragmentation

Mount options
+73 −199
Original line number Diff line number Diff line
@@ -31,21 +31,26 @@
#include "dat.h"
#include "alloc.h"

struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *bmap)
{
	return nilfs_dat_inode(NILFS_I_NILFS(bmap->b_inode));
}

int nilfs_bmap_lookup_at_level(struct nilfs_bmap *bmap, __u64 key, int level,
			       __u64 *ptrp)
{
	__u64 ptr;
	sector_t blocknr;
	int ret;

	down_read(&bmap->b_sem);
	ret = bmap->b_ops->bop_lookup(bmap, key, level, ptrp);
	if (ret < 0)
		goto out;
	if (bmap->b_pops->bpop_translate != NULL) {
		ret = bmap->b_pops->bpop_translate(bmap, *ptrp, &ptr);
		if (ret < 0)
			goto out;
		*ptrp = ptr;
	if (NILFS_BMAP_USE_VBN(bmap)) {
		ret = nilfs_dat_translate(nilfs_bmap_get_dat(bmap), *ptrp,
					  &blocknr);
		if (!ret)
			*ptrp = blocknr;
	}

 out:
@@ -53,6 +58,16 @@ int nilfs_bmap_lookup_at_level(struct nilfs_bmap *bmap, __u64 key, int level,
	return ret;
}

int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp,
			     unsigned maxblocks)
{
	int ret;

	down_read(&bmap->b_sem);
	ret = bmap->b_ops->bop_lookup_contig(bmap, key, ptrp, maxblocks);
	up_read(&bmap->b_sem);
	return ret;
}

/**
 * nilfs_bmap_lookup - find a record
@@ -101,8 +116,7 @@ static int nilfs_bmap_do_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
			if (n < 0)
				return n;
			ret = nilfs_btree_convert_and_insert(
				bmap, key, ptr, keys, ptrs, n,
				NILFS_BMAP_LARGE_LOW, NILFS_BMAP_LARGE_HIGH);
				bmap, key, ptr, keys, ptrs, n);
			if (ret == 0)
				bmap->b_u.u_flags |= NILFS_BMAP_LARGE;

@@ -158,8 +172,7 @@ static int nilfs_bmap_do_delete(struct nilfs_bmap *bmap, __u64 key)
			if (n < 0)
				return n;
			ret = nilfs_direct_delete_and_convert(
				bmap, key, keys, ptrs, n,
				NILFS_BMAP_SMALL_LOW, NILFS_BMAP_SMALL_HIGH);
				bmap, key, keys, ptrs, n);
			if (ret == 0)
				bmap->b_u.u_flags &= ~NILFS_BMAP_LARGE;

@@ -417,38 +430,6 @@ void nilfs_bmap_sub_blocks(const struct nilfs_bmap *bmap, int n)
		mark_inode_dirty(bmap->b_inode);
}

int nilfs_bmap_get_block(const struct nilfs_bmap *bmap, __u64 ptr,
			 struct buffer_head **bhp)
{
	return nilfs_btnode_get(&NILFS_BMAP_I(bmap)->i_btnode_cache,
				ptr, 0, bhp, 0);
}

void nilfs_bmap_put_block(const struct nilfs_bmap *bmap,
			  struct buffer_head *bh)
{
	brelse(bh);
}

int nilfs_bmap_get_new_block(const struct nilfs_bmap *bmap, __u64 ptr,
			     struct buffer_head **bhp)
{
	int ret;

	ret = nilfs_btnode_get(&NILFS_BMAP_I(bmap)->i_btnode_cache,
			       ptr, 0, bhp, 1);
	if (ret < 0)
		return ret;
	set_buffer_nilfs_volatile(*bhp);
	return 0;
}

void nilfs_bmap_delete_block(const struct nilfs_bmap *bmap,
			     struct buffer_head *bh)
{
	nilfs_btnode_delete(bh);
}

__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
			      const struct buffer_head *bh)
{
@@ -476,11 +457,6 @@ __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key)
		return NILFS_BMAP_INVALID_PTR;
}

static struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *bmap)
{
	return nilfs_dat_inode(NILFS_I_NILFS(bmap->b_inode));
}

#define NILFS_BMAP_GROUP_DIV	8
__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *bmap)
{
@@ -493,63 +469,50 @@ __u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *bmap)
		(entries_per_group / NILFS_BMAP_GROUP_DIV);
}

static int nilfs_bmap_prepare_alloc_v(struct nilfs_bmap *bmap,
int nilfs_bmap_prepare_alloc_v(struct nilfs_bmap *bmap,
				 union nilfs_bmap_ptr_req *req)
{
	return nilfs_dat_prepare_alloc(nilfs_bmap_get_dat(bmap), &req->bpr_req);
}

static void nilfs_bmap_commit_alloc_v(struct nilfs_bmap *bmap,
void nilfs_bmap_commit_alloc_v(struct nilfs_bmap *bmap,
				 union nilfs_bmap_ptr_req *req)
{
	nilfs_dat_commit_alloc(nilfs_bmap_get_dat(bmap), &req->bpr_req);
}

static void nilfs_bmap_abort_alloc_v(struct nilfs_bmap *bmap,
void nilfs_bmap_abort_alloc_v(struct nilfs_bmap *bmap,
			      union nilfs_bmap_ptr_req *req)
{
	nilfs_dat_abort_alloc(nilfs_bmap_get_dat(bmap), &req->bpr_req);
}

static int nilfs_bmap_prepare_start_v(struct nilfs_bmap *bmap,
				      union nilfs_bmap_ptr_req *req)
{
	return nilfs_dat_prepare_start(nilfs_bmap_get_dat(bmap), &req->bpr_req);
}

static void nilfs_bmap_commit_start_v(struct nilfs_bmap *bmap,
				      union nilfs_bmap_ptr_req *req,
int nilfs_bmap_start_v(struct nilfs_bmap *bmap, union nilfs_bmap_ptr_req *req,
		       sector_t blocknr)
{
	nilfs_dat_commit_start(nilfs_bmap_get_dat(bmap), &req->bpr_req,
			       blocknr);
}
	struct inode *dat = nilfs_bmap_get_dat(bmap);
	int ret;

static void nilfs_bmap_abort_start_v(struct nilfs_bmap *bmap,
				     union nilfs_bmap_ptr_req *req)
{
	nilfs_dat_abort_start(nilfs_bmap_get_dat(bmap), &req->bpr_req);
	ret = nilfs_dat_prepare_start(dat, &req->bpr_req);
	if (likely(!ret))
		nilfs_dat_commit_start(dat, &req->bpr_req, blocknr);
	return ret;
}

static int nilfs_bmap_prepare_end_v(struct nilfs_bmap *bmap,
int nilfs_bmap_prepare_end_v(struct nilfs_bmap *bmap,
			     union nilfs_bmap_ptr_req *req)
{
	return nilfs_dat_prepare_end(nilfs_bmap_get_dat(bmap), &req->bpr_req);
}

static void nilfs_bmap_commit_end_v(struct nilfs_bmap *bmap,
				    union nilfs_bmap_ptr_req *req)
{
	nilfs_dat_commit_end(nilfs_bmap_get_dat(bmap), &req->bpr_req, 0);
}

static void nilfs_bmap_commit_end_vmdt(struct nilfs_bmap *bmap,
void nilfs_bmap_commit_end_v(struct nilfs_bmap *bmap,
			     union nilfs_bmap_ptr_req *req)
{
	nilfs_dat_commit_end(nilfs_bmap_get_dat(bmap), &req->bpr_req, 1);
	nilfs_dat_commit_end(nilfs_bmap_get_dat(bmap), &req->bpr_req,
			     bmap->b_ptr_type == NILFS_BMAP_PTR_VS);
}

static void nilfs_bmap_abort_end_v(struct nilfs_bmap *bmap,
void nilfs_bmap_abort_end_v(struct nilfs_bmap *bmap,
			    union nilfs_bmap_ptr_req *req)
{
	nilfs_dat_abort_end(nilfs_bmap_get_dat(bmap), &req->bpr_req);
@@ -566,128 +529,44 @@ int nilfs_bmap_mark_dirty(const struct nilfs_bmap *bmap, __u64 vblocknr)
	return nilfs_dat_mark_dirty(nilfs_bmap_get_dat(bmap), vblocknr);
}

int nilfs_bmap_prepare_update(struct nilfs_bmap *bmap,
int nilfs_bmap_prepare_update_v(struct nilfs_bmap *bmap,
				union nilfs_bmap_ptr_req *oldreq,
				union nilfs_bmap_ptr_req *newreq)
{
	struct inode *dat = nilfs_bmap_get_dat(bmap);
	int ret;

	ret = bmap->b_pops->bpop_prepare_end_ptr(bmap, oldreq);
	ret = nilfs_dat_prepare_end(dat, &oldreq->bpr_req);
	if (ret < 0)
		return ret;
	ret = bmap->b_pops->bpop_prepare_alloc_ptr(bmap, newreq);
	ret = nilfs_dat_prepare_alloc(dat, &newreq->bpr_req);
	if (ret < 0)
		bmap->b_pops->bpop_abort_end_ptr(bmap, oldreq);
		nilfs_dat_abort_end(dat, &oldreq->bpr_req);

	return ret;
}

void nilfs_bmap_commit_update(struct nilfs_bmap *bmap,
void nilfs_bmap_commit_update_v(struct nilfs_bmap *bmap,
				union nilfs_bmap_ptr_req *oldreq,
				union nilfs_bmap_ptr_req *newreq)
{
	bmap->b_pops->bpop_commit_end_ptr(bmap, oldreq);
	bmap->b_pops->bpop_commit_alloc_ptr(bmap, newreq);
	struct inode *dat = nilfs_bmap_get_dat(bmap);

	nilfs_dat_commit_end(dat, &oldreq->bpr_req,
			     bmap->b_ptr_type == NILFS_BMAP_PTR_VS);
	nilfs_dat_commit_alloc(dat, &newreq->bpr_req);
}

void nilfs_bmap_abort_update(struct nilfs_bmap *bmap,
void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap,
			       union nilfs_bmap_ptr_req *oldreq,
			       union nilfs_bmap_ptr_req *newreq)
{
	bmap->b_pops->bpop_abort_end_ptr(bmap, oldreq);
	bmap->b_pops->bpop_abort_alloc_ptr(bmap, newreq);
}

static int nilfs_bmap_translate_v(const struct nilfs_bmap *bmap, __u64 ptr,
				  __u64 *ptrp)
{
	sector_t blocknr;
	int ret;

	ret = nilfs_dat_translate(nilfs_bmap_get_dat(bmap), ptr, &blocknr);
	if (ret < 0)
		return ret;
	if (ptrp != NULL)
		*ptrp = blocknr;
	return 0;
}

static int nilfs_bmap_prepare_alloc_p(struct nilfs_bmap *bmap,
				      union nilfs_bmap_ptr_req *req)
{
	/* ignore target ptr */
	req->bpr_ptr = bmap->b_last_allocated_ptr++;
	return 0;
}
	struct inode *dat = nilfs_bmap_get_dat(bmap);

static void nilfs_bmap_commit_alloc_p(struct nilfs_bmap *bmap,
				      union nilfs_bmap_ptr_req *req)
{
	/* do nothing */
	nilfs_dat_abort_end(dat, &oldreq->bpr_req);
	nilfs_dat_abort_alloc(dat, &newreq->bpr_req);
}

static void nilfs_bmap_abort_alloc_p(struct nilfs_bmap *bmap,
				     union nilfs_bmap_ptr_req *req)
{
	bmap->b_last_allocated_ptr--;
}

static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_v = {
	.bpop_prepare_alloc_ptr	=	nilfs_bmap_prepare_alloc_v,
	.bpop_commit_alloc_ptr	=	nilfs_bmap_commit_alloc_v,
	.bpop_abort_alloc_ptr	=	nilfs_bmap_abort_alloc_v,
	.bpop_prepare_start_ptr	=	nilfs_bmap_prepare_start_v,
	.bpop_commit_start_ptr	=	nilfs_bmap_commit_start_v,
	.bpop_abort_start_ptr	=	nilfs_bmap_abort_start_v,
	.bpop_prepare_end_ptr	=	nilfs_bmap_prepare_end_v,
	.bpop_commit_end_ptr	=	nilfs_bmap_commit_end_v,
	.bpop_abort_end_ptr	=	nilfs_bmap_abort_end_v,

	.bpop_translate		=	nilfs_bmap_translate_v,
};

static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_vmdt = {
	.bpop_prepare_alloc_ptr	=	nilfs_bmap_prepare_alloc_v,
	.bpop_commit_alloc_ptr	=	nilfs_bmap_commit_alloc_v,
	.bpop_abort_alloc_ptr	=	nilfs_bmap_abort_alloc_v,
	.bpop_prepare_start_ptr	=	nilfs_bmap_prepare_start_v,
	.bpop_commit_start_ptr	=	nilfs_bmap_commit_start_v,
	.bpop_abort_start_ptr	=	nilfs_bmap_abort_start_v,
	.bpop_prepare_end_ptr	=	nilfs_bmap_prepare_end_v,
	.bpop_commit_end_ptr	=	nilfs_bmap_commit_end_vmdt,
	.bpop_abort_end_ptr	=	nilfs_bmap_abort_end_v,

	.bpop_translate		=	nilfs_bmap_translate_v,
};

static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_p = {
	.bpop_prepare_alloc_ptr	=	nilfs_bmap_prepare_alloc_p,
	.bpop_commit_alloc_ptr	=	nilfs_bmap_commit_alloc_p,
	.bpop_abort_alloc_ptr	=	nilfs_bmap_abort_alloc_p,
	.bpop_prepare_start_ptr	=	NULL,
	.bpop_commit_start_ptr	=	NULL,
	.bpop_abort_start_ptr	=	NULL,
	.bpop_prepare_end_ptr	=	NULL,
	.bpop_commit_end_ptr	=	NULL,
	.bpop_abort_end_ptr	=	NULL,

	.bpop_translate		=	NULL,
};

static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_gc = {
	.bpop_prepare_alloc_ptr	=	NULL,
	.bpop_commit_alloc_ptr	=	NULL,
	.bpop_abort_alloc_ptr	=	NULL,
	.bpop_prepare_start_ptr	=	NULL,
	.bpop_commit_start_ptr	=	NULL,
	.bpop_abort_start_ptr	=	NULL,
	.bpop_prepare_end_ptr	=	NULL,
	.bpop_commit_end_ptr	=	NULL,
	.bpop_abort_end_ptr	=	NULL,

	.bpop_translate		=	NULL,
};

static struct lock_class_key nilfs_bmap_dat_lock_key;

/**
@@ -714,31 +593,26 @@ int nilfs_bmap_read(struct nilfs_bmap *bmap, struct nilfs_inode *raw_inode)
	bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode;
	switch (bmap->b_inode->i_ino) {
	case NILFS_DAT_INO:
		bmap->b_pops = &nilfs_bmap_ptr_ops_p;
		bmap->b_last_allocated_key = 0;	/* XXX: use macro */
		bmap->b_ptr_type = NILFS_BMAP_PTR_P;
		bmap->b_last_allocated_key = 0;
		bmap->b_last_allocated_ptr = NILFS_BMAP_NEW_PTR_INIT;
		lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
		break;
	case NILFS_CPFILE_INO:
	case NILFS_SUFILE_INO:
		bmap->b_pops = &nilfs_bmap_ptr_ops_vmdt;
		bmap->b_last_allocated_key = 0;	/* XXX: use macro */
		bmap->b_ptr_type = NILFS_BMAP_PTR_VS;
		bmap->b_last_allocated_key = 0;
		bmap->b_last_allocated_ptr = NILFS_BMAP_INVALID_PTR;
		break;
	default:
		bmap->b_pops = &nilfs_bmap_ptr_ops_v;
		bmap->b_last_allocated_key = 0;	/* XXX: use macro */
		bmap->b_ptr_type = NILFS_BMAP_PTR_VM;
		bmap->b_last_allocated_key = 0;
		bmap->b_last_allocated_ptr = NILFS_BMAP_INVALID_PTR;
		break;
	}

	return (bmap->b_u.u_flags & NILFS_BMAP_LARGE) ?
		nilfs_btree_init(bmap,
				 NILFS_BMAP_LARGE_LOW,
				 NILFS_BMAP_LARGE_HIGH) :
		nilfs_direct_init(bmap,
				  NILFS_BMAP_SMALL_LOW,
				  NILFS_BMAP_SMALL_HIGH);
		nilfs_btree_init(bmap) : nilfs_direct_init(bmap);
}

/**
@@ -764,7 +638,7 @@ void nilfs_bmap_init_gc(struct nilfs_bmap *bmap)
	memset(&bmap->b_u, 0, NILFS_BMAP_SIZE);
	init_rwsem(&bmap->b_sem);
	bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode;
	bmap->b_pops = &nilfs_bmap_ptr_ops_gc;
	bmap->b_ptr_type = NILFS_BMAP_PTR_U;
	bmap->b_last_allocated_key = 0;
	bmap->b_last_allocated_ptr = NILFS_BMAP_INVALID_PTR;
	bmap->b_state = 0;
+84 −51
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ struct nilfs_bmap_stats {
 */
struct nilfs_bmap_operations {
	int (*bop_lookup)(const struct nilfs_bmap *, __u64, int, __u64 *);
	int (*bop_lookup_contig)(const struct nilfs_bmap *, __u64, __u64 *,
				 unsigned);
	int (*bop_insert)(struct nilfs_bmap *, __u64, __u64);
	int (*bop_delete)(struct nilfs_bmap *, __u64);
	void (*bop_clear)(struct nilfs_bmap *);
@@ -86,34 +88,6 @@ struct nilfs_bmap_operations {
};


/**
 * struct nilfs_bmap_ptr_operations - bmap ptr operation table
 */
struct nilfs_bmap_ptr_operations {
	int (*bpop_prepare_alloc_ptr)(struct nilfs_bmap *,
				      union nilfs_bmap_ptr_req *);
	void (*bpop_commit_alloc_ptr)(struct nilfs_bmap *,
				      union nilfs_bmap_ptr_req *);
	void (*bpop_abort_alloc_ptr)(struct nilfs_bmap *,
				     union nilfs_bmap_ptr_req *);
	int (*bpop_prepare_start_ptr)(struct nilfs_bmap *,
				      union nilfs_bmap_ptr_req *);
	void (*bpop_commit_start_ptr)(struct nilfs_bmap *,
				      union nilfs_bmap_ptr_req *,
				      sector_t);
	void (*bpop_abort_start_ptr)(struct nilfs_bmap *,
				     union nilfs_bmap_ptr_req *);
	int (*bpop_prepare_end_ptr)(struct nilfs_bmap *,
				    union nilfs_bmap_ptr_req *);
	void (*bpop_commit_end_ptr)(struct nilfs_bmap *,
				    union nilfs_bmap_ptr_req *);
	void (*bpop_abort_end_ptr)(struct nilfs_bmap *,
				   union nilfs_bmap_ptr_req *);

	int (*bpop_translate)(const struct nilfs_bmap *, __u64, __u64 *);
};


#define NILFS_BMAP_SIZE		(NILFS_INODE_BMAP_SIZE * sizeof(__le64))
#define NILFS_BMAP_KEY_BIT	(sizeof(unsigned long) * 8 /* CHAR_BIT */)
#define NILFS_BMAP_NEW_PTR_INIT	\
@@ -131,11 +105,9 @@ static inline int nilfs_bmap_is_new_ptr(unsigned long ptr)
 * @b_sem: semaphore
 * @b_inode: owner of bmap
 * @b_ops: bmap operation table
 * @b_pops: bmap ptr operation table
 * @b_low: low watermark of conversion
 * @b_high: high watermark of conversion
 * @b_last_allocated_key: last allocated key for data block
 * @b_last_allocated_ptr: last allocated ptr for data block
 * @b_ptr_type: pointer type
 * @b_state: state
 */
struct nilfs_bmap {
@@ -146,14 +118,22 @@ struct nilfs_bmap {
	struct rw_semaphore b_sem;
	struct inode *b_inode;
	const struct nilfs_bmap_operations *b_ops;
	const struct nilfs_bmap_ptr_operations *b_pops;
	__u64 b_low;
	__u64 b_high;
	__u64 b_last_allocated_key;
	__u64 b_last_allocated_ptr;
	int b_ptr_type;
	int b_state;
};

/* pointer type */
#define NILFS_BMAP_PTR_P	0	/* physical block number (i.e. LBN) */
#define NILFS_BMAP_PTR_VS	1	/* virtual block number (single
					   version) */
#define NILFS_BMAP_PTR_VM	2	/* virtual block number (has multiple
					   versions) */
#define NILFS_BMAP_PTR_U	(-1)	/* never perform pointer operations */

#define NILFS_BMAP_USE_VBN(bmap)	((bmap)->b_ptr_type > 0)

/* state */
#define NILFS_BMAP_DIRTY	0x00000001

@@ -162,6 +142,7 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *);
int nilfs_bmap_read(struct nilfs_bmap *, struct nilfs_inode *);
void nilfs_bmap_write(struct nilfs_bmap *, struct nilfs_inode *);
int nilfs_bmap_lookup(struct nilfs_bmap *, unsigned long, unsigned long *);
int nilfs_bmap_lookup_contig(struct nilfs_bmap *, __u64, __u64 *, unsigned);
int nilfs_bmap_insert(struct nilfs_bmap *, unsigned long, unsigned long);
int nilfs_bmap_delete(struct nilfs_bmap *, unsigned long);
int nilfs_bmap_last_key(struct nilfs_bmap *, unsigned long *);
@@ -182,7 +163,67 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *, struct nilfs_bmap *);
/*
 * Internal use only
 */
struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *);
int nilfs_bmap_prepare_alloc_v(struct nilfs_bmap *,
			       union nilfs_bmap_ptr_req *);
void nilfs_bmap_commit_alloc_v(struct nilfs_bmap *,
			       union nilfs_bmap_ptr_req *);
void nilfs_bmap_abort_alloc_v(struct nilfs_bmap *,
			      union nilfs_bmap_ptr_req *);

static inline int nilfs_bmap_prepare_alloc_ptr(struct nilfs_bmap *bmap,
					       union nilfs_bmap_ptr_req *req)
{
	if (NILFS_BMAP_USE_VBN(bmap))
		return nilfs_bmap_prepare_alloc_v(bmap, req);
	/* ignore target ptr */
	req->bpr_ptr = bmap->b_last_allocated_ptr++;
	return 0;
}

static inline void nilfs_bmap_commit_alloc_ptr(struct nilfs_bmap *bmap,
					       union nilfs_bmap_ptr_req *req)
{
	if (NILFS_BMAP_USE_VBN(bmap))
		nilfs_bmap_commit_alloc_v(bmap, req);
}

static inline void nilfs_bmap_abort_alloc_ptr(struct nilfs_bmap *bmap,
					      union nilfs_bmap_ptr_req *req)
{
	if (NILFS_BMAP_USE_VBN(bmap))
		nilfs_bmap_abort_alloc_v(bmap, req);
	else
		bmap->b_last_allocated_ptr--;
}

int nilfs_bmap_prepare_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *);
void nilfs_bmap_commit_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *);
void nilfs_bmap_abort_end_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *);

static inline int nilfs_bmap_prepare_end_ptr(struct nilfs_bmap *bmap,
					     union nilfs_bmap_ptr_req *req)
{
	return NILFS_BMAP_USE_VBN(bmap) ?
		nilfs_bmap_prepare_end_v(bmap, req) : 0;
}

static inline void nilfs_bmap_commit_end_ptr(struct nilfs_bmap *bmap,
					     union nilfs_bmap_ptr_req *req)
{
	if (NILFS_BMAP_USE_VBN(bmap))
		nilfs_bmap_commit_end_v(bmap, req);
}

static inline void nilfs_bmap_abort_end_ptr(struct nilfs_bmap *bmap,
					    union nilfs_bmap_ptr_req *req)
{
	if (NILFS_BMAP_USE_VBN(bmap))
		nilfs_bmap_abort_end_v(bmap, req);
}

int nilfs_bmap_start_v(struct nilfs_bmap *, union nilfs_bmap_ptr_req *,
		       sector_t);
int nilfs_bmap_move_v(const struct nilfs_bmap *, __u64, sector_t);
int nilfs_bmap_mark_dirty(const struct nilfs_bmap *, __u64);

@@ -193,13 +234,13 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *,
__u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64);
__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *);

int nilfs_bmap_prepare_update(struct nilfs_bmap *,
int nilfs_bmap_prepare_update_v(struct nilfs_bmap *,
				union nilfs_bmap_ptr_req *,
				union nilfs_bmap_ptr_req *);
void nilfs_bmap_commit_update(struct nilfs_bmap *,
void nilfs_bmap_commit_update_v(struct nilfs_bmap *,
				union nilfs_bmap_ptr_req *,
				union nilfs_bmap_ptr_req *);
void nilfs_bmap_abort_update(struct nilfs_bmap *,
void nilfs_bmap_abort_update_v(struct nilfs_bmap *,
			       union nilfs_bmap_ptr_req *,
			       union nilfs_bmap_ptr_req *);

@@ -207,14 +248,6 @@ void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int);
void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int);


int nilfs_bmap_get_block(const struct nilfs_bmap *, __u64,
			 struct buffer_head **);
void nilfs_bmap_put_block(const struct nilfs_bmap *, struct buffer_head *);
int nilfs_bmap_get_new_block(const struct nilfs_bmap *, __u64,
			     struct buffer_head **);
void nilfs_bmap_delete_block(const struct nilfs_bmap *, struct buffer_head *);


/* Assume that bmap semaphore is locked. */
static inline int nilfs_bmap_dirty(const struct nilfs_bmap *bmap)
{
+6 −3
Original line number Diff line number Diff line
@@ -46,15 +46,18 @@ void nilfs_btnode_cache_init_once(struct address_space *btnc)
	INIT_LIST_HEAD(&btnc->i_mmap_nonlinear);
}

static struct address_space_operations def_btnode_aops;
static struct address_space_operations def_btnode_aops = {
	.sync_page		= block_sync_page,
};

void nilfs_btnode_cache_init(struct address_space *btnc)
void nilfs_btnode_cache_init(struct address_space *btnc,
			     struct backing_dev_info *bdi)
{
	btnc->host = NULL;  /* can safely set to host inode ? */
	btnc->flags = 0;
	mapping_set_gfp_mask(btnc, GFP_NOFS);
	btnc->assoc_mapping = NULL;
	btnc->backing_dev_info = &default_backing_dev_info;
	btnc->backing_dev_info = bdi;
	btnc->a_ops = &def_btnode_aops;
}

+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ struct nilfs_btnode_chkey_ctxt {
};

void nilfs_btnode_cache_init_once(struct address_space *);
void nilfs_btnode_cache_init(struct address_space *);
void nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *);
void nilfs_btnode_cache_clear(struct address_space *);
int nilfs_btnode_submit_block(struct address_space *, __u64, sector_t,
			      struct buffer_head **, int);
Loading