Commit 9fc0178c 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:
  nilfs2: fix possible mismatch of sufile counters on recovery
  nilfs2: segment usage file cleanups
  nilfs2: fix wrong accounting and duplicate brelse in nilfs_sufile_set_error
  nilfs2: simplify handling of active state of segments fix
  nilfs2: remove module version
  nilfs2: fix lockdep recursive locking warning on meta data files
  nilfs2: fix lockdep recursive locking warning on bmap
  nilfs2: return f_fsid for statfs2
parents 2b6b6d38 c85399c2
...@@ -688,6 +688,8 @@ static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_gc = { ...@@ -688,6 +688,8 @@ static const struct nilfs_bmap_ptr_operations nilfs_bmap_ptr_ops_gc = {
.bpop_translate = NULL, .bpop_translate = NULL,
}; };
static struct lock_class_key nilfs_bmap_dat_lock_key;
/** /**
* nilfs_bmap_read - read a bmap from an inode * nilfs_bmap_read - read a bmap from an inode
* @bmap: bmap * @bmap: bmap
...@@ -715,6 +717,7 @@ int nilfs_bmap_read(struct nilfs_bmap *bmap, struct nilfs_inode *raw_inode) ...@@ -715,6 +717,7 @@ int nilfs_bmap_read(struct nilfs_bmap *bmap, struct nilfs_inode *raw_inode)
bmap->b_pops = &nilfs_bmap_ptr_ops_p; bmap->b_pops = &nilfs_bmap_ptr_ops_p;
bmap->b_last_allocated_key = 0; /* XXX: use macro */ bmap->b_last_allocated_key = 0; /* XXX: use macro */
bmap->b_last_allocated_ptr = NILFS_BMAP_NEW_PTR_INIT; bmap->b_last_allocated_ptr = NILFS_BMAP_NEW_PTR_INIT;
lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
break; break;
case NILFS_CPFILE_INO: case NILFS_CPFILE_INO:
case NILFS_SUFILE_INO: case NILFS_SUFILE_INO:
...@@ -772,6 +775,7 @@ void nilfs_bmap_init_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap) ...@@ -772,6 +775,7 @@ void nilfs_bmap_init_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap)
{ {
memcpy(gcbmap, bmap, sizeof(union nilfs_bmap_union)); memcpy(gcbmap, bmap, sizeof(union nilfs_bmap_union));
init_rwsem(&gcbmap->b_sem); init_rwsem(&gcbmap->b_sem);
lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
gcbmap->b_inode = &NILFS_BMAP_I(gcbmap)->vfs_inode; gcbmap->b_inode = &NILFS_BMAP_I(gcbmap)->vfs_inode;
} }
...@@ -779,5 +783,6 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap) ...@@ -779,5 +783,6 @@ void nilfs_bmap_commit_gcdat(struct nilfs_bmap *gcbmap, struct nilfs_bmap *bmap)
{ {
memcpy(bmap, gcbmap, sizeof(union nilfs_bmap_union)); memcpy(bmap, gcbmap, sizeof(union nilfs_bmap_union));
init_rwsem(&bmap->b_sem); init_rwsem(&bmap->b_sem);
lockdep_set_class(&bmap->b_sem, &nilfs_bmap_dat_lock_key);
bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode; bmap->b_inode = &NILFS_BMAP_I(bmap)->vfs_inode;
} }
...@@ -34,11 +34,6 @@ ...@@ -34,11 +34,6 @@
#include "bmap.h" #include "bmap.h"
#include "bmap_union.h" #include "bmap_union.h"
/*
* NILFS filesystem version
*/
#define NILFS_VERSION "2.0.5"
/* /*
* nilfs inode data in memory * nilfs inode data in memory
*/ */
......
...@@ -413,7 +413,6 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, ...@@ -413,7 +413,6 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
struct nilfs_segment_entry *ent, *n; struct nilfs_segment_entry *ent, *n;
struct inode *sufile = nilfs->ns_sufile; struct inode *sufile = nilfs->ns_sufile;
__u64 segnum[4]; __u64 segnum[4];
time_t mtime;
int err; int err;
int i; int i;
...@@ -442,24 +441,13 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, ...@@ -442,24 +441,13 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
* Collecting segments written after the latest super root. * Collecting segments written after the latest super root.
* These are marked dirty to avoid being reallocated in the next write. * These are marked dirty to avoid being reallocated in the next write.
*/ */
mtime = get_seconds();
list_for_each_entry_safe(ent, n, head, list) { list_for_each_entry_safe(ent, n, head, list) {
if (ent->segnum == segnum[0]) { if (ent->segnum != segnum[0]) {
list_del(&ent->list); err = nilfs_sufile_scrap(sufile, ent->segnum);
nilfs_free_segment_entry(ent);
continue;
}
err = nilfs_open_segment_entry(ent, sufile);
if (unlikely(err)) if (unlikely(err))
goto failed; goto failed;
if (!nilfs_segment_usage_dirty(ent->raw_su)) {
/* make the segment garbage */
ent->raw_su->su_nblocks = cpu_to_le32(0);
ent->raw_su->su_lastmod = cpu_to_le32(mtime);
nilfs_segment_usage_set_dirty(ent->raw_su);
} }
list_del(&ent->list); list_del(&ent->list);
nilfs_close_segment_entry(ent, sufile);
nilfs_free_segment_entry(ent); nilfs_free_segment_entry(ent);
} }
......
This diff is collapsed.
...@@ -36,9 +36,6 @@ static inline unsigned long nilfs_sufile_get_nsegments(struct inode *sufile) ...@@ -36,9 +36,6 @@ static inline unsigned long nilfs_sufile_get_nsegments(struct inode *sufile)
} }
int nilfs_sufile_alloc(struct inode *, __u64 *); int nilfs_sufile_alloc(struct inode *, __u64 *);
int nilfs_sufile_cancel_free(struct inode *, __u64);
int nilfs_sufile_freev(struct inode *, __u64 *, size_t);
int nilfs_sufile_free(struct inode *, __u64);
int nilfs_sufile_get_segment_usage(struct inode *, __u64, int nilfs_sufile_get_segment_usage(struct inode *, __u64,
struct nilfs_segment_usage **, struct nilfs_segment_usage **,
struct buffer_head **); struct buffer_head **);
...@@ -46,9 +43,83 @@ void nilfs_sufile_put_segment_usage(struct inode *, __u64, ...@@ -46,9 +43,83 @@ void nilfs_sufile_put_segment_usage(struct inode *, __u64,
struct buffer_head *); struct buffer_head *);
int nilfs_sufile_get_stat(struct inode *, struct nilfs_sustat *); int nilfs_sufile_get_stat(struct inode *, struct nilfs_sustat *);
int nilfs_sufile_get_ncleansegs(struct inode *, unsigned long *); int nilfs_sufile_get_ncleansegs(struct inode *, unsigned long *);
int nilfs_sufile_set_error(struct inode *, __u64);
ssize_t nilfs_sufile_get_suinfo(struct inode *, __u64, struct nilfs_suinfo *, ssize_t nilfs_sufile_get_suinfo(struct inode *, __u64, struct nilfs_suinfo *,
size_t); size_t);
int nilfs_sufile_update(struct inode *, __u64, int,
void (*dofunc)(struct inode *, __u64,
struct buffer_head *,
struct buffer_head *));
void nilfs_sufile_do_cancel_free(struct inode *, __u64, struct buffer_head *,
struct buffer_head *);
void nilfs_sufile_do_scrap(struct inode *, __u64, struct buffer_head *,
struct buffer_head *);
void nilfs_sufile_do_free(struct inode *, __u64, struct buffer_head *,
struct buffer_head *);
void nilfs_sufile_do_set_error(struct inode *, __u64, struct buffer_head *,
struct buffer_head *);
/**
* nilfs_sufile_cancel_free -
* @sufile: inode of segment usage file
* @segnum: segment number
*
* Description:
*
* Return Value: On success, 0 is returned. On error, one of the following
* negative error codes is returned.
*
* %-EIO - I/O error.
*
* %-ENOMEM - Insufficient amount of memory available.
*/
static inline int nilfs_sufile_cancel_free(struct inode *sufile, __u64 segnum)
{
return nilfs_sufile_update(sufile, segnum, 0,
nilfs_sufile_do_cancel_free);
}
/**
* nilfs_sufile_scrap - make a segment garbage
* @sufile: inode of segment usage file
* @segnum: segment number to be freed
*/
static inline int nilfs_sufile_scrap(struct inode *sufile, __u64 segnum)
{
return nilfs_sufile_update(sufile, segnum, 1, nilfs_sufile_do_scrap);
}
/**
* nilfs_sufile_free - free segment
* @sufile: inode of segment usage file
* @segnum: segment number to be freed
*/
static inline int nilfs_sufile_free(struct inode *sufile, __u64 segnum)
{
return nilfs_sufile_update(sufile, segnum, 0, nilfs_sufile_do_free);
}
/**
* nilfs_sufile_set_error - mark a segment as erroneous
* @sufile: inode of segment usage file
* @segnum: segment number
*
* Description: nilfs_sufile_set_error() marks the segment specified by
* @segnum as erroneous. The error segment will never be used again.
*
* Return Value: On success, 0 is returned. On error, one of the following
* negative error codes is returned.
*
* %-EIO - I/O error.
*
* %-ENOMEM - Insufficient amount of memory available.
*
* %-EINVAL - Invalid segment usage number.
*/
static inline int nilfs_sufile_set_error(struct inode *sufile, __u64 segnum)
{
return nilfs_sufile_update(sufile, segnum, 0,
nilfs_sufile_do_set_error);
}
#endif /* _NILFS_SUFILE_H */ #endif /* _NILFS_SUFILE_H */
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
MODULE_AUTHOR("NTT Corp."); MODULE_AUTHOR("NTT Corp.");
MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem " MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem "
"(NILFS)"); "(NILFS)");
MODULE_VERSION(NILFS_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int nilfs_remount(struct super_block *sb, int *flags, char *data); static int nilfs_remount(struct super_block *sb, int *flags, char *data);
...@@ -476,11 +475,12 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -476,11 +475,12 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
{ {
struct super_block *sb = dentry->d_sb; struct super_block *sb = dentry->d_sb;
struct nilfs_sb_info *sbi = NILFS_SB(sb); struct nilfs_sb_info *sbi = NILFS_SB(sb);
struct the_nilfs *nilfs = sbi->s_nilfs;
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
unsigned long long blocks; unsigned long long blocks;
unsigned long overhead; unsigned long overhead;
unsigned long nrsvblocks; unsigned long nrsvblocks;
sector_t nfreeblocks; sector_t nfreeblocks;
struct the_nilfs *nilfs = sbi->s_nilfs;
int err; int err;
/* /*
...@@ -514,6 +514,9 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -514,6 +514,9 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_files = atomic_read(&sbi->s_inodes_count); buf->f_files = atomic_read(&sbi->s_inodes_count);
buf->f_ffree = 0; /* nilfs_count_free_inodes(sb); */ buf->f_ffree = 0; /* nilfs_count_free_inodes(sb); */
buf->f_namelen = NILFS_NAME_LEN; buf->f_namelen = NILFS_NAME_LEN;
buf->f_fsid.val[0] = (u32)id;
buf->f_fsid.val[1] = (u32)(id >> 32);
return 0; return 0;
} }
......
...@@ -115,6 +115,7 @@ void put_nilfs(struct the_nilfs *nilfs) ...@@ -115,6 +115,7 @@ void put_nilfs(struct the_nilfs *nilfs)
static int nilfs_load_super_root(struct the_nilfs *nilfs, static int nilfs_load_super_root(struct the_nilfs *nilfs,
struct nilfs_sb_info *sbi, sector_t sr_block) struct nilfs_sb_info *sbi, sector_t sr_block)
{ {
static struct lock_class_key dat_lock_key;
struct buffer_head *bh_sr; struct buffer_head *bh_sr;
struct nilfs_super_root *raw_sr; struct nilfs_super_root *raw_sr;
struct nilfs_super_block **sbp = nilfs->ns_sbp; struct nilfs_super_block **sbp = nilfs->ns_sbp;
...@@ -163,6 +164,9 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs, ...@@ -163,6 +164,9 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs,
if (unlikely(err)) if (unlikely(err))
goto failed_sufile; goto failed_sufile;
lockdep_set_class(&NILFS_MDT(nilfs->ns_dat)->mi_sem, &dat_lock_key);
lockdep_set_class(&NILFS_MDT(nilfs->ns_gc_dat)->mi_sem, &dat_lock_key);
nilfs_mdt_set_shadow(nilfs->ns_dat, nilfs->ns_gc_dat); nilfs_mdt_set_shadow(nilfs->ns_dat, nilfs->ns_gc_dat);
nilfs_mdt_set_entry_size(nilfs->ns_cpfile, checkpoint_size, nilfs_mdt_set_entry_size(nilfs->ns_cpfile, checkpoint_size,
sizeof(struct nilfs_cpfile_header)); sizeof(struct nilfs_cpfile_header));
......
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