*
* This function does not issue actual read request of the specified data
* block. It is done by VFS.
- * Bulk read for direct-io is not supported yet. (should be supported)
*/
int nilfs_get_block(struct inode *inode, sector_t blkoff,
struct buffer_head *bh_result, int create)
{
struct nilfs_inode_info *ii = NILFS_I(inode);
- unsigned long blknum = 0;
+ __u64 blknum = 0;
int err = 0, ret;
struct inode *dat = nilfs_dat_inode(NILFS_I_NILFS(inode));
+ unsigned maxblocks = bh_result->b_size >> inode->i_blkbits;
- /* This exclusion control is a workaround; should be revised */
- down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
- ret = nilfs_bmap_lookup(ii->i_bmap, (unsigned long)blkoff, &blknum);
- up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
- if (ret == 0) { /* found */
+ down_read(&NILFS_MDT(dat)->mi_sem);
+ ret = nilfs_bmap_lookup_contig(ii->i_bmap, blkoff, &blknum, maxblocks);
+ up_read(&NILFS_MDT(dat)->mi_sem);
+ if (ret >= 0) { /* found */
map_bh(bh_result, inode->i_sb, blknum);
+ if (ret > 0)
+ bh_result->b_size = (ret << inode->i_blkbits);
goto out;
}
/* data block was not found */
return size;
}
-struct address_space_operations nilfs_aops = {
+const struct address_space_operations nilfs_aops = {
.writepage = nilfs_writepage,
.readpage = nilfs_readpage,
- /* .sync_page = nilfs_sync_page, */
+ .sync_page = block_sync_page,
.writepages = nilfs_writepages,
.set_page_dirty = nilfs_set_page_dirty,
.readpages = nilfs_readpages,
/* .releasepage = nilfs_releasepage, */
.invalidatepage = block_invalidatepage,
.direct_IO = nilfs_direct_IO,
+ .is_partially_uptodate = block_is_partially_uptodate,
};
struct inode *nilfs_new_inode(struct inode *dir, int mode)
/* ii->i_file_acl = 0; */
/* ii->i_dir_acl = 0; */
- ii->i_dtime = 0;
ii->i_dir_start_lookup = 0;
-#ifdef CONFIG_NILFS_FS_POSIX_ACL
- ii->i_acl = NULL;
- ii->i_default_acl = NULL;
-#endif
ii->i_cno = 0;
nilfs_set_inode_flags(inode);
spin_lock(&sbi->s_next_gen_lock);
inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
- inode->i_atime.tv_nsec = 0;
- inode->i_ctime.tv_nsec = 0;
- inode->i_mtime.tv_nsec = 0;
- ii->i_dtime = le64_to_cpu(raw_inode->i_dtime);
- if (inode->i_nlink == 0 && (inode->i_mode == 0 || ii->i_dtime))
+ inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
+ inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
+ inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
+ if (inode->i_nlink == 0 && inode->i_mode == 0)
return -EINVAL; /* this inode is deleted */
inode->i_blocks = le64_to_cpu(raw_inode->i_blocks);
return 0;
}
-static int nilfs_read_sketch_inode(struct inode *inode)
-{
- struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
- int err = 0;
-
- if (sbi->s_snapshot_cno) {
- struct the_nilfs *nilfs = sbi->s_nilfs;
- struct buffer_head *bh_cp;
- struct nilfs_checkpoint *raw_cp;
-
- err = nilfs_cpfile_get_checkpoint(
- nilfs->ns_cpfile, sbi->s_snapshot_cno, 0, &raw_cp,
- &bh_cp);
- if (likely(!err)) {
- if (!nilfs_checkpoint_sketch(raw_cp))
- inode->i_size = 0;
- nilfs_cpfile_put_checkpoint(
- nilfs->ns_cpfile, sbi->s_snapshot_cno, bh_cp);
- }
- inode->i_flags |= S_NOCMTIME;
- }
- return err;
-}
-
static int __nilfs_read_inode(struct super_block *sb, unsigned long ino,
struct inode *inode)
{
raw_inode = nilfs_ifile_map_inode(sbi->s_ifile, ino, bh);
-#ifdef CONFIG_NILFS_FS_POSIX_ACL
- ii->i_acl = NILFS_ACL_NOT_CACHED;
- ii->i_default_acl = NILFS_ACL_NOT_CACHED;
-#endif
- if (nilfs_read_inode_common(inode, raw_inode))
+ err = nilfs_read_inode_common(inode, raw_inode);
+ if (err)
goto failed_unmap;
if (S_ISREG(inode->i_mode)) {
inode->i_op = &nilfs_file_inode_operations;
inode->i_fop = &nilfs_file_operations;
inode->i_mapping->a_ops = &nilfs_aops;
- if (unlikely(inode->i_ino == NILFS_SKETCH_INO)) {
- err = nilfs_read_sketch_inode(inode);
- if (unlikely(err))
- goto failed_unmap;
- }
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = &nilfs_dir_inode_operations;
inode->i_fop = &nilfs_dir_operations;
raw_inode->i_size = cpu_to_le64(inode->i_size);
raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
+ raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+ raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
- raw_inode->i_dtime = cpu_to_le64(ii->i_dtime);
raw_inode->i_flags = cpu_to_le32(ii->i_flags);
raw_inode->i_generation = cpu_to_le32(inode->i_generation);
atomic_add(nr_dirty, &sbi->s_nilfs->ns_ndirtyblks);
- if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state) ||
- unlikely(inode->i_ino == NILFS_SKETCH_INO))
+ if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state))
return 0;
spin_lock(&sbi->s_inode_lock);
return;
}
nilfs_transaction_begin(inode->i_sb, &ti, 0);
- if (likely(inode->i_ino != NILFS_SKETCH_INO))
- nilfs_mark_inode_dirty(inode);
+ nilfs_mark_inode_dirty(inode);
nilfs_transaction_commit(inode->i_sb); /* never fails */
}