Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207551
b: refs/heads/master
c: 9df2f85
h: refs/heads/master
i:
  207549: 9329a42
  207547: b3473f9
  207543: 2909d1c
  207535: 84112ea
  207519: d632286
  207487: f6d7708
v: v3
  • Loading branch information
Al Viro committed Aug 9, 2010
1 parent 192de6e commit b9f742e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac14a95b5239d37b6082c3791b88d7ab4e8e444c
refs/heads/master: 9df2f85128def59185f8a1c584f8af41df17405a
70 changes: 32 additions & 38 deletions trunk/fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,35 +99,40 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
return ERR_PTR(-EIO);
}

static struct bfs_inode *find_inode(struct super_block *sb, u16 ino, struct buffer_head **p)
{
if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(sb)->si_lasti)) {
printf("Bad inode number %s:%08x\n", sb->s_id, ino);
return ERR_PTR(-EIO);
}

ino -= BFS_ROOT_INO;

*p = sb_bread(sb, 1 + ino / BFS_INODES_PER_BLOCK);
if (!*p) {
printf("Unable to read inode %s:%08x\n", sb->s_id, ino);
return ERR_PTR(-EIO);
}

return (struct bfs_inode *)(*p)->b_data + ino % BFS_INODES_PER_BLOCK;
}

static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
{
struct bfs_sb_info *info = BFS_SB(inode->i_sb);
unsigned int ino = (u16)inode->i_ino;
unsigned long i_sblock;
struct bfs_inode *di;
struct buffer_head *bh;
int block, off;
int err = 0;

dprintf("ino=%08x\n", ino);

if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) {
printf("Bad inode number %s:%08x\n", inode->i_sb->s_id, ino);
return -EIO;
}
di = find_inode(inode->i_sb, ino, &bh);
if (IS_ERR(di))
return PTR_ERR(di);

mutex_lock(&info->bfs_lock);
block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
bh = sb_bread(inode->i_sb, block);
if (!bh) {
printf("Unable to read inode %s:%08x\n",
inode->i_sb->s_id, ino);
mutex_unlock(&info->bfs_lock);
return -EIO;
}

off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
di = (struct bfs_inode *)bh->b_data + off;

if (ino == BFS_ROOT_INO)
di->i_vtype = cpu_to_le32(BFS_VDIR);
Expand Down Expand Up @@ -158,41 +163,31 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
return err;
}

static void bfs_delete_inode(struct inode *inode)
static void bfs_evict_inode(struct inode *inode)
{
unsigned long ino = inode->i_ino;
struct bfs_inode *di;
struct buffer_head *bh;
int block, off;
struct super_block *s = inode->i_sb;
struct bfs_sb_info *info = BFS_SB(s);
struct bfs_inode_info *bi = BFS_I(inode);

dprintf("ino=%08lx\n", ino);

truncate_inode_pages(&inode->i_data, 0);
invalidate_inode_buffers(inode);
end_writeback(inode);

if ((ino < BFS_ROOT_INO) || (ino > info->si_lasti)) {
printf("invalid ino=%08lx\n", ino);
if (inode->i_nlink)
return;
}

inode->i_size = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
mutex_lock(&info->bfs_lock);
mark_inode_dirty(inode);

block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
bh = sb_bread(s, block);
if (!bh) {
printf("Unable to read inode %s:%08lx\n",
inode->i_sb->s_id, ino);
mutex_unlock(&info->bfs_lock);
di = find_inode(s, inode->i_ino, &bh);
if (IS_ERR(di))
return;
}
off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
di = (struct bfs_inode *)bh->b_data + off;
memset((void *)di, 0, sizeof(struct bfs_inode));

mutex_lock(&info->bfs_lock);
/* clear on-disk inode */
memset(di, 0, sizeof(struct bfs_inode));
mark_buffer_dirty(bh);
brelse(bh);

Expand All @@ -214,7 +209,6 @@ static void bfs_delete_inode(struct inode *inode)
mark_buffer_dirty(info->si_sbh);
}
mutex_unlock(&info->bfs_lock);
clear_inode(inode);
}

static int bfs_sync_fs(struct super_block *sb, int wait)
Expand Down Expand Up @@ -319,7 +313,7 @@ static const struct super_operations bfs_sops = {
.alloc_inode = bfs_alloc_inode,
.destroy_inode = bfs_destroy_inode,
.write_inode = bfs_write_inode,
.delete_inode = bfs_delete_inode,
.evict_inode = bfs_evict_inode,
.put_super = bfs_put_super,
.write_super = bfs_write_super,
.sync_fs = bfs_sync_fs,
Expand Down

0 comments on commit b9f742e

Please sign in to comment.