Commit d7dbf4ff authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2: (23 commits)
  nilfs2: disallow remount of snapshot from/to a regular mount
  nilfs2: use huge_encode_dev/huge_decode_dev
  nilfs2: update comment on deactivate_super at nilfs_get_sb
  nilfs2: replace MS_VERBOSE with MS_SILENT
  nilfs2: add missing initialization of s_mode
  nilfs2: fix misuse of open_bdev_exclusive/close_bdev_exclusive
  nilfs2: enlarge s_volume_name member in nilfs_super_block
  nilfs2: use checkpoint number instead of timestamp to select super block
  nilfs2: add missing endian conversion on super block magic number
  nilfs2: make nilfs_sc_*_ops static
  nilfs2: add kernel doc comments to persistent object allocator functions
  nilfs2: change sc_timer from a pointer to an embedded one in struct nilfs_sc_info
  nilfs2: remove nilfs_segctor_init() in segment.c
  nilfs2: insert checkpoint number in segment summary header
  nilfs2: add a print message after loading nilfs2
  nilfs2: cleanup multi kmem_cache_{create,destroy} code
  nilfs2: move out checksum routines to segment buffer code
  nilfs2: move pointer to super root block into logs
  nilfs2: change default of 'errors' mount option to 'remount-ro' mode
  nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path()
  ...
parents 677abe49 d240e067
...@@ -50,8 +50,8 @@ NILFS2 supports the following mount options: ...@@ -50,8 +50,8 @@ NILFS2 supports the following mount options:
(*) == default (*) == default
nobarrier Disables barriers. nobarrier Disables barriers.
errors=continue(*) Keep going on a filesystem error. errors=continue Keep going on a filesystem error.
errors=remount-ro Remount the filesystem read-only on an error. errors=remount-ro(*) Remount the filesystem read-only on an error.
errors=panic Panic and halt the machine if an error occurs. errors=panic Panic and halt the machine if an error occurs.
cp=n Specify the checkpoint-number of the snapshot to be cp=n Specify the checkpoint-number of the snapshot to be
mounted. Checkpoints and snapshots are listed by lscp mounted. Checkpoints and snapshots are listed by lscp
......
This diff is collapsed.
...@@ -29,6 +29,13 @@ ...@@ -29,6 +29,13 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/fs.h> #include <linux/fs.h>
/**
* nilfs_palloc_entries_per_group - get the number of entries per group
* @inode: inode of metadata file using this allocator
*
* The number of entries per group is defined by the number of bits
* that a bitmap block can maintain.
*/
static inline unsigned long static inline unsigned long
nilfs_palloc_entries_per_group(const struct inode *inode) nilfs_palloc_entries_per_group(const struct inode *inode)
{ {
......
...@@ -31,63 +31,16 @@ ...@@ -31,63 +31,16 @@
#include "alloc.h" #include "alloc.h"
#include "dat.h" #include "dat.h"
/** static struct nilfs_btree_path *nilfs_btree_alloc_path(void)
* struct nilfs_btree_path - A path on which B-tree operations are executed
* @bp_bh: buffer head of node block
* @bp_sib_bh: buffer head of sibling node block
* @bp_index: index of child node
* @bp_oldreq: ptr end request for old ptr
* @bp_newreq: ptr alloc request for new ptr
* @bp_op: rebalance operation
*/
struct nilfs_btree_path {
struct buffer_head *bp_bh;
struct buffer_head *bp_sib_bh;
int bp_index;
union nilfs_bmap_ptr_req bp_oldreq;
union nilfs_bmap_ptr_req bp_newreq;
struct nilfs_btnode_chkey_ctxt bp_ctxt;
void (*bp_op)(struct nilfs_btree *, struct nilfs_btree_path *,
int, __u64 *, __u64 *);
};
/*
* B-tree path operations
*/
static struct kmem_cache *nilfs_btree_path_cache;
int __init nilfs_btree_path_cache_init(void)
{
nilfs_btree_path_cache =
kmem_cache_create("nilfs2_btree_path_cache",
sizeof(struct nilfs_btree_path) *
NILFS_BTREE_LEVEL_MAX, 0, 0, NULL);
return (nilfs_btree_path_cache != NULL) ? 0 : -ENOMEM;
}
void nilfs_btree_path_cache_destroy(void)
{
kmem_cache_destroy(nilfs_btree_path_cache);
}
static inline struct nilfs_btree_path *nilfs_btree_alloc_path(void)
{
return kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
}
static inline void nilfs_btree_free_path(struct nilfs_btree_path *path)
{ {
kmem_cache_free(nilfs_btree_path_cache, path); struct nilfs_btree_path *path;
} int level = NILFS_BTREE_LEVEL_DATA;
static void nilfs_btree_init_path(struct nilfs_btree_path *path) path = kmem_cache_alloc(nilfs_btree_path_cache, GFP_NOFS);
{ if (path == NULL)
int level; goto out;
for (level = NILFS_BTREE_LEVEL_DATA; for (; level < NILFS_BTREE_LEVEL_MAX; level++) {
level < NILFS_BTREE_LEVEL_MAX;
level++) {
path[level].bp_bh = NULL; path[level].bp_bh = NULL;
path[level].bp_sib_bh = NULL; path[level].bp_sib_bh = NULL;
path[level].bp_index = 0; path[level].bp_index = 0;
...@@ -95,15 +48,19 @@ static void nilfs_btree_init_path(struct nilfs_btree_path *path) ...@@ -95,15 +48,19 @@ static void nilfs_btree_init_path(struct nilfs_btree_path *path)
path[level].bp_newreq.bpr_ptr = NILFS_BMAP_INVALID_PTR; path[level].bp_newreq.bpr_ptr = NILFS_BMAP_INVALID_PTR;
path[level].bp_op = NULL; path[level].bp_op = NULL;
} }
out:
return path;
} }
static void nilfs_btree_release_path(struct nilfs_btree_path *path) static void nilfs_btree_free_path(struct nilfs_btree_path *path)
{ {
int level; int level = NILFS_BTREE_LEVEL_DATA;
for (level = NILFS_BTREE_LEVEL_DATA; level < NILFS_BTREE_LEVEL_MAX; for (; level < NILFS_BTREE_LEVEL_MAX; level++)
level++)
brelse(path[level].bp_bh); brelse(path[level].bp_bh);
kmem_cache_free(nilfs_btree_path_cache, path);
} }
/* /*
...@@ -566,14 +523,12 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap, ...@@ -566,14 +523,12 @@ static int nilfs_btree_lookup(const struct nilfs_bmap *bmap,
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level); ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
if (ptrp != NULL) if (ptrp != NULL)
*ptrp = ptr; *ptrp = ptr;
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
...@@ -594,7 +549,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap, ...@@ -594,7 +549,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level); ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -655,7 +610,6 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap, ...@@ -655,7 +610,6 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *bmap,
*ptrp = ptr; *ptrp = ptr;
ret = cnt; ret = cnt;
out: out:
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
} }
...@@ -1123,7 +1077,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr) ...@@ -1123,7 +1077,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
ret = nilfs_btree_do_lookup(btree, path, key, NULL, ret = nilfs_btree_do_lookup(btree, path, key, NULL,
NILFS_BTREE_LEVEL_NODE_MIN); NILFS_BTREE_LEVEL_NODE_MIN);
...@@ -1140,7 +1093,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr) ...@@ -1140,7 +1093,6 @@ static int nilfs_btree_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
nilfs_bmap_add_blocks(bmap, stats.bs_nblocks); nilfs_bmap_add_blocks(bmap, stats.bs_nblocks);
out: out:
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
} }
...@@ -1456,7 +1408,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key) ...@@ -1456,7 +1408,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
ret = nilfs_btree_do_lookup(btree, path, key, NULL, ret = nilfs_btree_do_lookup(btree, path, key, NULL,
NILFS_BTREE_LEVEL_NODE_MIN); NILFS_BTREE_LEVEL_NODE_MIN);
if (ret < 0) if (ret < 0)
...@@ -1473,7 +1425,6 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key) ...@@ -1473,7 +1425,6 @@ static int nilfs_btree_delete(struct nilfs_bmap *bmap, __u64 key)
nilfs_bmap_sub_blocks(bmap, stats.bs_nblocks); nilfs_bmap_sub_blocks(bmap, stats.bs_nblocks);
out: out:
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
} }
...@@ -1488,11 +1439,9 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp) ...@@ -1488,11 +1439,9 @@ static int nilfs_btree_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL); ret = nilfs_btree_do_lookup_last(btree, path, keyp, NULL);
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
...@@ -1923,7 +1872,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap, ...@@ -1923,7 +1872,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
if (buffer_nilfs_node(bh)) { if (buffer_nilfs_node(bh)) {
node = (struct nilfs_btree_node *)bh->b_data; node = (struct nilfs_btree_node *)bh->b_data;
...@@ -1947,7 +1895,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap, ...@@ -1947,7 +1895,6 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
nilfs_btree_propagate_p(btree, path, level, bh); nilfs_btree_propagate_p(btree, path, level, bh);
out: out:
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
...@@ -2108,7 +2055,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap, ...@@ -2108,7 +2055,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
if (buffer_nilfs_node(*bh)) { if (buffer_nilfs_node(*bh)) {
node = (struct nilfs_btree_node *)(*bh)->b_data; node = (struct nilfs_btree_node *)(*bh)->b_data;
...@@ -2130,7 +2076,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap, ...@@ -2130,7 +2076,6 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo); nilfs_btree_assign_p(btree, path, level, bh, blocknr, binfo);
out: out:
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
...@@ -2175,7 +2120,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level) ...@@ -2175,7 +2120,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
path = nilfs_btree_alloc_path(); path = nilfs_btree_alloc_path();
if (path == NULL) if (path == NULL)
return -ENOMEM; return -ENOMEM;
nilfs_btree_init_path(path);
ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1); ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1);
if (ret < 0) { if (ret < 0) {
...@@ -2195,7 +2139,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level) ...@@ -2195,7 +2139,6 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
nilfs_bmap_set_dirty(&btree->bt_bmap); nilfs_bmap_set_dirty(&btree->bt_bmap);
out: out:
nilfs_btree_release_path(path);
nilfs_btree_free_path(path); nilfs_btree_free_path(path);
return ret; return ret;
} }
......
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
#include "btnode.h" #include "btnode.h"
#include "bmap.h" #include "bmap.h"
struct nilfs_btree;
struct nilfs_btree_path;
/** /**
* struct nilfs_btree - B-tree structure * struct nilfs_btree - B-tree structure
* @bt_bmap: bmap base structure * @bt_bmap: bmap base structure
...@@ -41,6 +38,25 @@ struct nilfs_btree { ...@@ -41,6 +38,25 @@ struct nilfs_btree {
struct nilfs_bmap bt_bmap; struct nilfs_bmap bt_bmap;
}; };
/**
* struct nilfs_btree_path - A path on which B-tree operations are executed
* @bp_bh: buffer head of node block
* @bp_sib_bh: buffer head of sibling node block
* @bp_index: index of child node
* @bp_oldreq: ptr end request for old ptr
* @bp_newreq: ptr alloc request for new ptr
* @bp_op: rebalance operation
*/
struct nilfs_btree_path {
struct buffer_head *bp_bh;
struct buffer_head *bp_sib_bh;
int bp_index;
union nilfs_bmap_ptr_req bp_oldreq;
union nilfs_bmap_ptr_req bp_newreq;
struct nilfs_btnode_chkey_ctxt bp_ctxt;
void (*bp_op)(struct nilfs_btree *, struct nilfs_btree_path *,
int, __u64 *, __u64 *);
};
#define NILFS_BTREE_ROOT_SIZE NILFS_BMAP_SIZE #define NILFS_BTREE_ROOT_SIZE NILFS_BMAP_SIZE
#define NILFS_BTREE_ROOT_NCHILDREN_MAX \ #define NILFS_BTREE_ROOT_NCHILDREN_MAX \
...@@ -57,6 +73,7 @@ struct nilfs_btree { ...@@ -57,6 +73,7 @@ struct nilfs_btree {
#define NILFS_BTREE_KEY_MIN ((__u64)0) #define NILFS_BTREE_KEY_MIN ((__u64)0)
#define NILFS_BTREE_KEY_MAX (~(__u64)0) #define NILFS_BTREE_KEY_MAX (~(__u64)0)
extern struct kmem_cache *nilfs_btree_path_cache;
int nilfs_btree_path_cache_init(void); int nilfs_btree_path_cache_init(void);
void nilfs_btree_path_cache_destroy(void); void nilfs_btree_path_cache_destroy(void);
......
...@@ -451,7 +451,7 @@ static int __nilfs_read_inode(struct super_block *sb, unsigned long ino, ...@@ -451,7 +451,7 @@ static int __nilfs_read_inode(struct super_block *sb, unsigned long ino,
inode->i_op = &nilfs_special_inode_operations; inode->i_op = &nilfs_special_inode_operations;
init_special_inode( init_special_inode(
inode, inode->i_mode, inode, inode->i_mode,
new_decode_dev(le64_to_cpu(raw_inode->i_device_code))); huge_decode_dev(le64_to_cpu(raw_inode->i_device_code)));
} }
nilfs_ifile_unmap_inode(sbi->s_ifile, ino, bh); nilfs_ifile_unmap_inode(sbi->s_ifile, ino, bh);
brelse(bh); brelse(bh);
...@@ -511,7 +511,7 @@ void nilfs_write_inode_common(struct inode *inode, ...@@ -511,7 +511,7 @@ void nilfs_write_inode_common(struct inode *inode,
nilfs_bmap_write(ii->i_bmap, raw_inode); nilfs_bmap_write(ii->i_bmap, raw_inode);
else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
raw_inode->i_device_code = raw_inode->i_device_code =
cpu_to_le64(new_encode_dev(inode->i_rdev)); cpu_to_le64(huge_encode_dev(inode->i_rdev));
/* When extending inode, nilfs->ns_inode_size should be checked /* When extending inode, nilfs->ns_inode_size should be checked
for substitutions of appended fields */ for substitutions of appended fields */
} }
......
...@@ -105,6 +105,8 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi, ...@@ -105,6 +105,8 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi,
ssi->nsumblk = DIV_ROUND_UP(ssi->sumbytes, blocksize); ssi->nsumblk = DIV_ROUND_UP(ssi->sumbytes, blocksize);
ssi->nfileblk = ssi->nblocks - ssi->nsumblk - !!NILFS_SEG_HAS_SR(ssi); ssi->nfileblk = ssi->nblocks - ssi->nsumblk - !!NILFS_SEG_HAS_SR(ssi);
/* need to verify ->ss_bytes field if read ->ss_cno */
} }
/** /**
......
...@@ -40,35 +40,10 @@ struct nilfs_write_info { ...@@ -40,35 +40,10 @@ struct nilfs_write_info {
sector_t blocknr; sector_t blocknr;
}; };
static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf, static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
struct the_nilfs *nilfs); struct the_nilfs *nilfs);
static int nilfs_segbuf_wait(struct nilfs_segment_buffer *segbuf); static int nilfs_segbuf_wait(struct nilfs_segment_buffer *segbuf);
static struct kmem_cache *nilfs_segbuf_cachep;
static void nilfs_segbuf_init_once(void *obj)
{
memset(obj, 0, sizeof(struct nilfs_segment_buffer));
}
int __init nilfs_init_segbuf_cache(void)
{
nilfs_segbuf_cachep =
kmem_cache_create("nilfs2_segbuf_cache",
sizeof(struct nilfs_segment_buffer),
0, SLAB_RECLAIM_ACCOUNT,
nilfs_segbuf_init_once);
return (nilfs_segbuf_cachep == NULL) ? -ENOMEM : 0;
}
void nilfs_destroy_segbuf_cache(void)
{
kmem_cache_destroy(nilfs_segbuf_cachep);
}
struct nilfs_segment_buffer *nilfs_segbuf_new(struct super_block *sb) struct nilfs_segment_buffer *nilfs_segbuf_new(struct super_block *sb)
{ {
struct nilfs_segment_buffer *segbuf; struct nilfs_segment_buffer *segbuf;
...@@ -81,6 +56,7 @@ struct nilfs_segment_buffer *nilfs_segbuf_new(struct super_block *sb) ...@@ -81,6 +56,7 @@ struct nilfs_segment_buffer *nilfs_segbuf_new(struct super_block *sb)
INIT_LIST_HEAD(&segbuf->sb_list); INIT_LIST_HEAD(&segbuf->sb_list);
INIT_LIST_HEAD(&segbuf->sb_segsum_buffers); INIT_LIST_HEAD(&segbuf->sb_segsum_buffers);
INIT_LIST_HEAD(&segbuf->sb_payload_buffers); INIT_LIST_HEAD(&segbuf->sb_payload_buffers);
segbuf->sb_super_root = NULL;
init_completion(&segbuf->sb_bio_event); init_completion(&segbuf->sb_bio_event);
atomic_set(&segbuf->sb_err, 0); atomic_set(&segbuf->sb_err, 0);
...@@ -158,7 +134,7 @@ int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *segbuf, ...@@ -158,7 +134,7 @@ int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *segbuf,
} }
int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags, int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags,
time_t ctime) time_t ctime, __u64 cno)
{ {
int err; int err;
...@@ -171,6 +147,7 @@ int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags, ...@@ -171,6 +147,7 @@ int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags,
segbuf->sb_sum.sumbytes = sizeof(struct nilfs_segment_summary); segbuf->sb_sum.sumbytes = sizeof(struct nilfs_segment_summary);
segbuf->sb_sum.nfinfo = segbuf->sb_sum.nfileblk = 0; segbuf->sb_sum.nfinfo = segbuf->sb_sum.nfileblk = 0;
segbuf->sb_sum.ctime = ctime; segbuf->sb_sum.ctime = ctime;
segbuf->sb_sum.cno = cno;
return 0; return 0;
} }
...@@ -196,13 +173,14 @@ void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *segbuf) ...@@ -196,13 +173,14 @@ void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *segbuf)
raw_sum->ss_nfinfo = cpu_to_le32(segbuf->sb_sum.nfinfo); raw_sum->ss_nfinfo = cpu_to_le32(segbuf->sb_sum.nfinfo);
raw_sum->ss_sumbytes = cpu_to_le32(segbuf->sb_sum.sumbytes); raw_sum->ss_sumbytes = cpu_to_le32(segbuf->sb_sum.sumbytes);
raw_sum->ss_pad = 0; raw_sum->ss_pad = 0;
raw_sum->ss_cno = cpu_to_le64(segbuf->sb_sum.cno);
} }
/* /*
* CRC calculation routines * CRC calculation routines
*/ */
void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf, static void
u32 seed) nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf, u32 seed)
{ {
struct buffer_head *bh; struct buffer_head *bh;
struct nilfs_segment_summary *raw_sum; struct nilfs_segment_summary *raw_sum;
...@@ -229,7 +207,7 @@ void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf, ...@@ -229,7 +207,7 @@ void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf,
raw_sum->ss_sumsum = cpu_to_le32(crc); raw_sum->ss_sumsum = cpu_to_le32(crc);
} }
void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf, static void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
u32 seed) u32 seed)
{ {
struct buffer_head *bh; struct buffer_head *bh;
...@@ -256,6 +234,20 @@ void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf, ...@@ -256,6 +234,20 @@ void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
raw_sum->ss_datasum = cpu_to_le32(crc); raw_sum->ss_datasum = cpu_to_le32(crc);
} }
static void
nilfs_segbuf_fill_in_super_root_crc(struct nilfs_segment_buffer *segbuf,
u32 seed)
{
struct nilfs_super_root *raw_sr;
u32 crc;
raw_sr = (struct nilfs_super_root *)segbuf->sb_super_root->b_data;
crc = crc32_le(seed,
(unsigned char *)raw_sr + sizeof(raw_sr->sr_sum),
NILFS_SR_BYTES - sizeof(raw_sr->sr_sum));
raw_sr->sr_sum = cpu_to_le32(crc);
}
static void nilfs_release_buffers(struct list_head *list) static void nilfs_release_buffers(struct list_head *list)
{ {
struct buffer_head *bh, *n; struct buffer_head *bh, *n;
...@@ -282,6 +274,7 @@ static void nilfs_segbuf_clear(struct nilfs_segment_buffer *segbuf) ...@@ -282,6 +274,7 @@ static void nilfs_segbuf_clear(struct nilfs_segment_buffer *segbuf)
{ {
nilfs_release_buffers(&segbuf->sb_segsum_buffers); nilfs_release_buffers(&segbuf->sb_segsum_buffers);
nilfs_release_buffers(&segbuf->sb_payload_buffers); nilfs_release_buffers(&segbuf->sb_payload_buffers);
segbuf->sb_super_root = NULL;
} }
/* /*
...@@ -334,6 +327,23 @@ int nilfs_wait_on_logs(struct list_head *logs) ...@@ -334,6 +327,23 @@ int nilfs_wait_on_logs(struct list_head *logs)
return ret; return ret;
} }
/**
* nilfs_add_checksums_on_logs - add checksums on the logs
* @logs: list of segment buffers storing target logs
* @seed: checksum seed value
*/
void nilfs_add_checksums_on_logs(struct list_head *logs, u32 seed)
{
struct nilfs_segment_buffer *segbuf;
list_for_each_entry(segbuf, logs, sb_list) {
if (segbuf->sb_super_root)
nilfs_segbuf_fill_in_super_root_crc(segbuf, seed);
nilfs_segbuf_fill_in_segsum_crc(segbuf, seed);
nilfs_segbuf_fill_in_data_crc(segbuf, seed);
}
}
/* /*
* BIO operations * BIO operations
*/ */
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @sumbytes: Byte count of segment summary * @sumbytes: Byte count of segment summary
* @nfileblk: Total number of file blocks * @nfileblk: Total number of file blocks
* @seg_seq: Segment sequence number * @seg_seq: Segment sequence number
* @cno: Checkpoint number
* @ctime: Creation time * @ctime: Creation time
* @next: Block number of the next full segment * @next: Block number of the next full segment
*/ */
...@@ -48,6 +49,7 @@ struct nilfs_segsum_info { ...@@ -48,6 +49,7 @@ struct nilfs_segsum_info {
unsigned long sumbytes; unsigned long sumbytes;
unsigned long nfileblk; unsigned long nfileblk;
u64 seg_seq; u64 seg_seq;
__u64 cno;
time_t ctime; time_t ctime;
sector_t next; sector_t next;
}; };
...@@ -76,6 +78,7 @@ struct nilfs_segsum_info { ...@@ -76,6 +78,7 @@ struct nilfs_segsum_info {
* @sb_rest_blocks: Number of residual blocks in the current segment * @sb_rest_blocks: Number of residual blocks in the current segment
* @sb_segsum_buffers: List of buffers for segment summaries * @sb_segsum_buffers: List of buffers for segment summaries
* @sb_payload_buffers: List of buffers for segment payload * @sb_payload_buffers: List of buffers for segment payload
* @sb_super_root: Pointer to buffer storing a super root block (if exists)
* @sb_nbio: Number of flying bio requests * @sb_nbio: Number of flying bio requests
* @sb_err: I/O error status * @sb_err: I/O error status
* @sb_bio_event: Completion event of log writing * @sb_bio_event: Completion event of log writing
...@@ -95,6 +98,7 @@ struct nilfs_segment_buffer { ...@@ -95,6 +98,7 @@ struct nilfs_segment_buffer {
/* Buffers */ /* Buffers */
struct list_head sb_segsum_buffers; struct list_head sb_segsum_buffers;
struct list_head sb_payload_buffers; /* including super root */ struct list_head sb_payload_buffers; /* including super root */
struct buffer_head *sb_super_root;
/* io status */ /* io status */
int sb_nbio; int sb_nbio;
...@@ -121,6 +125,7 @@ struct nilfs_segment_buffer { ...@@ -121,6 +125,7 @@ struct nilfs_segment_buffer {
b_assoc_buffers)) b_assoc_buffers))
#define NILFS_SEGBUF_BH_IS_LAST(bh, head) ((bh)->b_assoc_buffers.next == head) #define NILFS_SEGBUF_BH_IS_LAST(bh, head) ((bh)->b_assoc_buffers.next == head)
extern struct kmem_cache *nilfs_segbuf_cachep;
int __init nilfs_init_segbuf_cache(void); int __init nilfs_init_segbuf_cache(void);
void nilfs_destroy_segbuf_cache(void); void nilfs_destroy_segbuf_cache(void);
...@@ -132,13 +137,11 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf, ...@@ -132,13 +137,11 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf,
struct nilfs_segment_buffer *prev); struct nilfs_segment_buffer *prev);
void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64, void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64,
struct the_nilfs *); struct the_nilfs *);
int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned, time_t); int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned, time_t, __u64);
int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *); int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *);
int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *, int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *,
struct buffer_head **); struct buffer_head **);
void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *); void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *);
void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *, u32);
void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *, u32);
static inline void static inline void
nilfs_segbuf_add_segsum_buffer(struct nilfs_segment_buffer *segbuf, nilfs_segbuf_add_segsum_buffer(struct nilfs_segment_buffer *segbuf,
...@@ -171,6 +174,7 @@ void nilfs_truncate_logs(struct list_head *logs, ...@@ -171,6 +174,7 @@ void nilfs_truncate_logs(struct list_head *logs,
struct nilfs_segment_buffer *last); struct nilfs_segment_buffer *last);
int nilfs_write_logs(struct list_head *logs, struct the_nilfs *nilfs); int nilfs_write_logs(struct list_head *logs, struct the_nilfs *nilfs);
int nilfs_wait_on_logs(struct list_head *logs); int nilfs_wait_on_logs(struct list_head *logs);
void nilfs_add_checksums_on_logs(struct list_head *logs, u32 seed);
static inline void nilfs_destroy_logs(struct list_head *logs) static inline void nilfs_destroy_logs(struct list_head *logs)
{ {
......
This diff is collapsed.
...@@ -100,7 +100,6 @@ struct nilfs_segsum_pointer { ...@@ -100,7 +100,6 @@ struct nilfs_segsum_pointer {
* @sc_write_logs: List of segment buffers to hold logs under writing * @sc_write_logs: List of segment buffers to hold logs under writing
* @sc_segbuf_nblocks: Number of available blocks in segment buffers. * @sc_segbuf_nblocks: Number of available blocks in segment buffers.
* @sc_curseg: Current segment buffer * @sc_curseg: Current segment buffer
* @sc_super_root: Pointer to the super root buffer
* @sc_stage: Collection stage * @sc_stage: Collection stage
* @sc_finfo_ptr: pointer to the current finfo struct in the segment summary * @sc_finfo_ptr: pointer to the current finfo struct in the segment summary
* @sc_binfo_ptr: pointer to the current binfo struct in the segment summary * @sc_binfo_ptr: pointer to the current binfo struct in the segment summary
...@@ -148,7 +147,6 @@ struct nilfs_sc_info { ...@@ -148,7 +147,6 @@ struct nilfs_sc_info {
struct list_head sc_write_logs; struct list_head sc_write_logs;
unsigned long sc_segbuf_nblocks; unsigned long sc_segbuf_nblocks;
struct nilfs_segment_buffer *sc_curseg; struct nilfs_segment_buffer *sc_curseg;
struct buffer_head *sc_super_root;
struct nilfs_cstage sc_stage; struct nilfs_cstage sc_stage;
...@@ -179,7 +177,7 @@ struct nilfs_sc_info { ...@@ -179,7 +177,7 @@ struct nilfs_sc_info {
unsigned long sc_lseg_stime; /* in 1/HZ seconds */ unsigned long sc_lseg_stime; /* in 1/HZ seconds */
unsigned long sc_watermark; unsigned long sc_watermark;
struct timer_list *sc_timer; struct timer_list sc_timer;
struct task_struct *sc_task; struct task_struct *sc_task;
}; };
...@@ -219,6 +217,8 @@ enum { ...@@ -219,6 +217,8 @@ enum {
*/ */
#define NILFS_SC_DEFAULT_WATERMARK 3600 #define NILFS_SC_DEFAULT_WATERMARK 3600
/* super.c */
extern struct kmem_cache *nilfs_transaction_cachep;
/* segment.c */ /* segment.c */
extern int nilfs_init_transaction_cache(void); extern int nilfs_init_transaction_cache(void);
......
This diff is collapsed.
...@@ -486,11 +486,15 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, ...@@ -486,11 +486,15 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,
printk(KERN_WARNING printk(KERN_WARNING
"NILFS warning: unable to read secondary superblock\n"); "NILFS warning: unable to read secondary superblock\n");
/*
* Compare two super blocks and set 1 in swp if the secondary
* super block is valid and newer. Otherwise, set 0 in swp.
*/
valid[0] = nilfs_valid_sb(sbp[0]); valid[0] = nilfs_valid_sb(sbp[0]);
valid[1] = nilfs_valid_sb(sbp[1]); valid[1] = nilfs_valid_sb(sbp[1]);
swp = valid[1] && swp = valid[1] && (!valid[0] ||
(!valid[0] || le64_to_cpu(sbp[1]->s_last_cno) >
le64_to_cpu(sbp[1]->s_wtime) > le64_to_cpu(sbp[0]->s_wtime)); le64_to_cpu(sbp[0]->s_last_cno));
if (valid[swp] && nilfs_sb2_bad_offset(sbp[swp], sb2off)) { if (valid[swp] && nilfs_sb2_bad_offset(sbp[swp], sb2off)) {
brelse(sbh[1]); brelse(sbh[1]);
......
...@@ -207,8 +207,7 @@ struct nilfs_super_block { ...@@ -207,8 +207,7 @@ struct nilfs_super_block {
__le16 s_segment_usage_size; /* Size of a segment usage */ __le16 s_segment_usage_size; /* Size of a segment usage */
__u8 s_uuid[16]; /* 128-bit uuid for volume */ __u8 s_uuid[16]; /* 128-bit uuid for volume */
char s_volume_name[16]; /* volume name */ char s_volume_name[80]; /* volume name */
char s_last_mounted[64]; /* directory where last mounted */
__le32 s_c_interval; /* Commit interval of segment */ __le32 s_c_interval; /* Commit interval of segment */
__le32 s_c_block_max; /* Threshold of data amount for __le32 s_c_block_max; /* Threshold of data amount for
...@@ -377,6 +376,7 @@ union nilfs_binfo { ...@@ -377,6 +376,7 @@ union nilfs_binfo {
* @ss_nfinfo: number of finfo structures * @ss_nfinfo: number of finfo structures
* @ss_sumbytes: total size of segment summary in bytes * @ss_sumbytes: total size of segment summary in bytes
* @ss_pad: padding * @ss_pad: padding
* @ss_cno: checkpoint number
*/ */
struct nilfs_segment_summary { struct nilfs_segment_summary {
__le32 ss_datasum; __le32 ss_datasum;
...@@ -391,6 +391,7 @@ struct nilfs_segment_summary { ...@@ -391,6 +391,7 @@ struct nilfs_segment_summary {
__le32 ss_nfinfo; __le32 ss_nfinfo;
__le32 ss_sumbytes; __le32 ss_sumbytes;
__le32 ss_pad; __le32 ss_pad;
__le64 ss_cno;
/* array of finfo structures */ /* array of finfo structures */
}; };
...@@ -437,10 +438,10 @@ struct nilfs_palloc_group_desc { ...@@ -437,10 +438,10 @@ struct nilfs_palloc_group_desc {
/** /**
* struct nilfs_dat_entry - disk address translation entry * struct nilfs_dat_entry - disk address translation entry
* @dt_blocknr: block number * @de_blocknr: block number
* @dt_start: start checkpoint number * @de_start: start checkpoint number
* @dt_end: end checkpoint number * @de_end: end checkpoint number
* @dt_rsv: reserved for future use * @de_rsv: reserved for future use
*/ */
struct nilfs_dat_entry { struct nilfs_dat_entry {
__le64 de_blocknr; __le64 de_blocknr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment