Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/ryusuke/nilfs2

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2:
  nilfs2: move NILFS_SUPER_MAGIC to linux/magic.h
  nilfs2: get rid of nilfs_sb_info structure
  nilfs2: use sb instance instead of nilfs_sb_info struct
  nilfs2: get rid of sc_sbi back pointer
  nilfs2: move log writer onto nilfs object
  nilfs2: move next generation counter into nilfs object
  nilfs2: move s_inode_lock and s_dirty_files into nilfs object
  nilfs2: move parameters on nilfs_sb_info into nilfs object
  nilfs2: move mount options to nilfs object
  nilfs2: record used amount of each checkpoint in checkpoint list
  nilfs2: optimize rec_len functions
  nilfs2: append blocksize info to warnings during loading super blocks
  nilfs2: add compat ioctl
  nilfs2: implement FS_IOC_GETFLAGS/SETFLAGS/GETVERSION
  nilfs2: tighten restrictions on inode flags
  nilfs2: mark S_NOATIME on inodes only if NOATIME attribute is set
  nilfs2: use common file attribute macros
  nilfs2: add free entries count only if clear bit operation succeeded
  nilfs2: decrement inodes count only if raw inode was successfully deleted
  • Loading branch information
Linus Torvalds committed Mar 19, 2011
2 parents a8c91da + 4d3cf1b commit 5bab188
Show file tree
Hide file tree
Showing 21 changed files with 513 additions and 499 deletions.
12 changes: 7 additions & 5 deletions fs/nilfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ void nilfs_palloc_commit_free_entry(struct inode *inode,
group_offset, bitmap))
printk(KERN_WARNING "%s: entry number %llu already freed\n",
__func__, (unsigned long long)req->pr_entry_nr);

nilfs_palloc_group_desc_add_entries(inode, group, desc, 1);
else
nilfs_palloc_group_desc_add_entries(inode, group, desc, 1);

kunmap(req->pr_bitmap_bh->b_page);
kunmap(req->pr_desc_bh->b_page);
Expand Down Expand Up @@ -558,8 +558,8 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode,
group_offset, bitmap))
printk(KERN_WARNING "%s: entry number %llu already freed\n",
__func__, (unsigned long long)req->pr_entry_nr);

nilfs_palloc_group_desc_add_entries(inode, group, desc, 1);
else
nilfs_palloc_group_desc_add_entries(inode, group, desc, 1);

kunmap(req->pr_bitmap_bh->b_page);
kunmap(req->pr_desc_bh->b_page);
Expand Down Expand Up @@ -665,7 +665,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
for (j = i, n = 0;
(j < nitems) && nilfs_palloc_group_is_in(inode, group,
entry_nrs[j]);
j++, n++) {
j++) {
nilfs_palloc_group(inode, entry_nrs[j], &group_offset);
if (!nilfs_clear_bit_atomic(
nilfs_mdt_bgl_lock(inode, group),
Expand All @@ -674,6 +674,8 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
"%s: entry number %llu already freed\n",
__func__,
(unsigned long long)entry_nrs[j]);
} else {
n++;
}
}
nilfs_palloc_group_desc_add_entries(inode, group, desc, n);
Expand Down
12 changes: 0 additions & 12 deletions fs/nilfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/errno.h>
#include "nilfs.h"
#include "bmap.h"
#include "sb.h"
#include "btree.h"
#include "direct.h"
#include "btnode.h"
Expand Down Expand Up @@ -425,17 +424,6 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap)
/*
* Internal use only
*/

void nilfs_bmap_add_blocks(const struct nilfs_bmap *bmap, int n)
{
inode_add_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n);
}

void nilfs_bmap_sub_blocks(const struct nilfs_bmap *bmap, int n)
{
inode_sub_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n);
}

__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
const struct buffer_head *bh)
{
Expand Down
3 changes: 0 additions & 3 deletions fs/nilfs2/bmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ __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 *);

void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int);
void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int);


/* Assume that bmap semaphore is locked. */
static inline int nilfs_bmap_dirty(const struct nilfs_bmap *bmap)
Expand Down
6 changes: 3 additions & 3 deletions fs/nilfs2/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ static int nilfs_btree_insert(struct nilfs_bmap *btree, __u64 key, __u64 ptr)
if (ret < 0)
goto out;
nilfs_btree_commit_insert(btree, path, level, key, ptr);
nilfs_bmap_add_blocks(btree, stats.bs_nblocks);
nilfs_inode_add_blocks(btree->b_inode, stats.bs_nblocks);

out:
nilfs_btree_free_path(path);
Expand Down Expand Up @@ -1511,7 +1511,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *btree, __u64 key)
if (ret < 0)
goto out;
nilfs_btree_commit_delete(btree, path, level, dat);
nilfs_bmap_sub_blocks(btree, stats.bs_nblocks);
nilfs_inode_sub_blocks(btree->b_inode, stats.bs_nblocks);

out:
nilfs_btree_free_path(path);
Expand Down Expand Up @@ -1776,7 +1776,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree,
return ret;
nilfs_btree_commit_convert_and_insert(btree, key, ptr, keys, ptrs, n,
di, ni, bh);
nilfs_bmap_add_blocks(btree, stats.bs_nblocks);
nilfs_inode_add_blocks(btree->b_inode, stats.bs_nblocks);
return 0;
}

Expand Down
5 changes: 1 addition & 4 deletions fs/nilfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
nilfs_commit_chunk(page, mapping, from, to);
nilfs_put_page(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME;
/* NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */
}

/*
Expand Down Expand Up @@ -531,7 +530,6 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
nilfs_set_de_type(de, inode);
nilfs_commit_chunk(page, page->mapping, from, to);
dir->i_mtime = dir->i_ctime = CURRENT_TIME;
/* NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */
nilfs_mark_inode_dirty(dir);
/* OFFSET_CACHE */
out_put:
Expand Down Expand Up @@ -579,7 +577,6 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
dir->inode = 0;
nilfs_commit_chunk(page, mapping, from, to);
inode->i_ctime = inode->i_mtime = CURRENT_TIME;
/* NILFS_I(inode)->i_flags &= ~NILFS_BTREE_FL; */
out:
nilfs_put_page(page);
return err;
Expand Down Expand Up @@ -684,7 +681,7 @@ const struct file_operations nilfs_dir_operations = {
.readdir = nilfs_readdir,
.unlocked_ioctl = nilfs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = nilfs_ioctl,
.compat_ioctl = nilfs_compat_ioctl,
#endif /* CONFIG_COMPAT */
.fsync = nilfs_sync_file,

Expand Down
4 changes: 2 additions & 2 deletions fs/nilfs2/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int nilfs_direct_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
if (NILFS_BMAP_USE_VBN(bmap))
nilfs_bmap_set_target_v(bmap, key, req.bpr_ptr);

nilfs_bmap_add_blocks(bmap, 1);
nilfs_inode_add_blocks(bmap->b_inode, 1);
}
return ret;
}
Expand All @@ -168,7 +168,7 @@ static int nilfs_direct_delete(struct nilfs_bmap *bmap, __u64 key)
if (!ret) {
nilfs_bmap_commit_end_ptr(bmap, &req, dat);
nilfs_direct_set_ptr(bmap, key, NILFS_BMAP_INVALID_PTR);
nilfs_bmap_sub_blocks(bmap, 1);
nilfs_inode_sub_blocks(bmap->b_inode, 1);
}
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/nilfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
struct nilfs_transaction_info ti;
int ret;

if (unlikely(nilfs_near_disk_full(NILFS_SB(inode->i_sb)->s_nilfs)))
if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info)))
return VM_FAULT_SIGBUS; /* -ENOSPC */

lock_page(page);
Expand Down Expand Up @@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = {
.aio_write = generic_file_aio_write,
.unlocked_ioctl = nilfs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = nilfs_ioctl,
.compat_ioctl = nilfs_compat_ioctl,
#endif /* CONFIG_COMPAT */
.mmap = nilfs_file_mmap,
.open = generic_file_open,
Expand Down
83 changes: 49 additions & 34 deletions fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ struct nilfs_iget_args {
int for_gc;
};

void nilfs_inode_add_blocks(struct inode *inode, int n)
{
struct nilfs_root *root = NILFS_I(inode)->i_root;

inode_add_bytes(inode, (1 << inode->i_blkbits) * n);
if (root)
atomic_add(n, &root->blocks_count);
}

void nilfs_inode_sub_blocks(struct inode *inode, int n)
{
struct nilfs_root *root = NILFS_I(inode)->i_root;

inode_sub_bytes(inode, (1 << inode->i_blkbits) * n);
if (root)
atomic_sub(n, &root->blocks_count);
}

/**
* nilfs_get_block() - get a file block on the filesystem (callback function)
* @inode - inode struct of the target file
Expand Down Expand Up @@ -277,7 +295,7 @@ const struct address_space_operations nilfs_aops = {
struct inode *nilfs_new_inode(struct inode *dir, int mode)
{
struct super_block *sb = dir->i_sb;
struct nilfs_sb_info *sbi = NILFS_SB(sb);
struct the_nilfs *nilfs = sb->s_fs_info;
struct inode *inode;
struct nilfs_inode_info *ii;
struct nilfs_root *root;
Expand Down Expand Up @@ -315,19 +333,16 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
/* No lock is needed; iget() ensures it. */
}

ii->i_flags = NILFS_I(dir)->i_flags;
if (S_ISLNK(mode))
ii->i_flags &= ~(NILFS_IMMUTABLE_FL | NILFS_APPEND_FL);
if (!S_ISDIR(mode))
ii->i_flags &= ~NILFS_DIRSYNC_FL;
ii->i_flags = nilfs_mask_flags(
mode, NILFS_I(dir)->i_flags & NILFS_FL_INHERITED);

/* ii->i_file_acl = 0; */
/* ii->i_dir_acl = 0; */
ii->i_dir_start_lookup = 0;
nilfs_set_inode_flags(inode);
spin_lock(&sbi->s_next_gen_lock);
inode->i_generation = sbi->s_next_generation++;
spin_unlock(&sbi->s_next_gen_lock);
spin_lock(&nilfs->ns_next_gen_lock);
inode->i_generation = nilfs->ns_next_generation++;
spin_unlock(&nilfs->ns_next_gen_lock);
insert_inode_hash(inode);

err = nilfs_init_acl(inode, dir);
Expand Down Expand Up @@ -359,17 +374,15 @@ void nilfs_set_inode_flags(struct inode *inode)

inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME |
S_DIRSYNC);
if (flags & NILFS_SYNC_FL)
if (flags & FS_SYNC_FL)
inode->i_flags |= S_SYNC;
if (flags & NILFS_APPEND_FL)
if (flags & FS_APPEND_FL)
inode->i_flags |= S_APPEND;
if (flags & NILFS_IMMUTABLE_FL)
if (flags & FS_IMMUTABLE_FL)
inode->i_flags |= S_IMMUTABLE;
#ifndef NILFS_ATIME_DISABLE
if (flags & NILFS_NOATIME_FL)
#endif
if (flags & FS_NOATIME_FL)
inode->i_flags |= S_NOATIME;
if (flags & NILFS_DIRSYNC_FL)
if (flags & FS_DIRSYNC_FL)
inode->i_flags |= S_DIRSYNC;
mapping_set_gfp_mask(inode->i_mapping,
mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
Expand Down Expand Up @@ -420,7 +433,7 @@ static int __nilfs_read_inode(struct super_block *sb,
struct nilfs_root *root, unsigned long ino,
struct inode *inode)
{
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
struct the_nilfs *nilfs = sb->s_fs_info;
struct buffer_head *bh;
struct nilfs_inode *raw_inode;
int err;
Expand Down Expand Up @@ -707,6 +720,7 @@ void nilfs_evict_inode(struct inode *inode)
struct nilfs_transaction_info ti;
struct super_block *sb = inode->i_sb;
struct nilfs_inode_info *ii = NILFS_I(inode);
int ret;

if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) {
if (inode->i_data.nrpages)
Expand All @@ -725,8 +739,9 @@ void nilfs_evict_inode(struct inode *inode)
nilfs_mark_inode_dirty(inode);
end_writeback(inode);

nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino);
atomic_dec(&ii->i_root->inodes_count);
ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino);
if (!ret)
atomic_dec(&ii->i_root->inodes_count);

nilfs_clear_inode(inode);

Expand Down Expand Up @@ -792,18 +807,18 @@ int nilfs_permission(struct inode *inode, int mask, unsigned int flags)

int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh)
{
struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
struct nilfs_inode_info *ii = NILFS_I(inode);
int err;

spin_lock(&sbi->s_inode_lock);
spin_lock(&nilfs->ns_inode_lock);
if (ii->i_bh == NULL) {
spin_unlock(&sbi->s_inode_lock);
spin_unlock(&nilfs->ns_inode_lock);
err = nilfs_ifile_get_inode_block(ii->i_root->ifile,
inode->i_ino, pbh);
if (unlikely(err))
return err;
spin_lock(&sbi->s_inode_lock);
spin_lock(&nilfs->ns_inode_lock);
if (ii->i_bh == NULL)
ii->i_bh = *pbh;
else {
Expand All @@ -814,55 +829,55 @@ int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh)
*pbh = ii->i_bh;

get_bh(*pbh);
spin_unlock(&sbi->s_inode_lock);
spin_unlock(&nilfs->ns_inode_lock);
return 0;
}

int nilfs_inode_dirty(struct inode *inode)
{
struct nilfs_inode_info *ii = NILFS_I(inode);
struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
int ret = 0;

if (!list_empty(&ii->i_dirty)) {
spin_lock(&sbi->s_inode_lock);
spin_lock(&nilfs->ns_inode_lock);
ret = test_bit(NILFS_I_DIRTY, &ii->i_state) ||
test_bit(NILFS_I_BUSY, &ii->i_state);
spin_unlock(&sbi->s_inode_lock);
spin_unlock(&nilfs->ns_inode_lock);
}
return ret;
}

int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty)
{
struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
struct nilfs_inode_info *ii = NILFS_I(inode);
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;

atomic_add(nr_dirty, &sbi->s_nilfs->ns_ndirtyblks);
atomic_add(nr_dirty, &nilfs->ns_ndirtyblks);

if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state))
return 0;

spin_lock(&sbi->s_inode_lock);
spin_lock(&nilfs->ns_inode_lock);
if (!test_bit(NILFS_I_QUEUED, &ii->i_state) &&
!test_bit(NILFS_I_BUSY, &ii->i_state)) {
/* Because this routine may race with nilfs_dispose_list(),
we have to check NILFS_I_QUEUED here, too. */
if (list_empty(&ii->i_dirty) && igrab(inode) == NULL) {
/* This will happen when somebody is freeing
this inode. */
nilfs_warning(sbi->s_super, __func__,
nilfs_warning(inode->i_sb, __func__,
"cannot get inode (ino=%lu)\n",
inode->i_ino);
spin_unlock(&sbi->s_inode_lock);
spin_unlock(&nilfs->ns_inode_lock);
return -EINVAL; /* NILFS_I_DIRTY may remain for
freeing inode */
}
list_del(&ii->i_dirty);
list_add_tail(&ii->i_dirty, &sbi->s_dirty_files);
list_add_tail(&ii->i_dirty, &nilfs->ns_dirty_files);
set_bit(NILFS_I_QUEUED, &ii->i_state);
}
spin_unlock(&sbi->s_inode_lock);
spin_unlock(&nilfs->ns_inode_lock);
return 0;
}

Expand Down
Loading

0 comments on commit 5bab188

Please sign in to comment.