28 #include <linux/uio.h>
81 struct buffer_head *bh_result,
int create)
87 unsigned maxblocks = bh_result->b_size >> inode->
i_blkbits;
93 map_bh(bh_result, inode->
i_sb, blknum);
102 bh_result->b_blocknr = 0;
107 (
unsigned long)bh_result);
117 "nilfs_get_block: a race condition "
118 "while inserting a data block. "
119 "(inode number=%lu, file block "
122 (
unsigned long long)blkoff);
131 set_buffer_new(bh_result);
132 set_buffer_delay(bh_result);
133 map_bh(bh_result, inode->
i_sb, 0);
187 struct inode *inode = page->
mapping->host;
203 static int nilfs_set_page_dirty(
struct page *page)
208 struct inode *inode = page->
mapping->host;
217 loff_t
pos,
unsigned len,
unsigned flags,
218 struct page **pagep,
void **fsdata)
221 struct inode *inode = mapping->
host;
230 loff_t isize = mapping->
host->i_size;
231 if (pos + len > isize)
239 static int nilfs_write_end(
struct file *file,
struct address_space *mapping,
240 loff_t pos,
unsigned len,
unsigned copied,
241 struct page *page,
void *fsdata)
243 struct inode *inode = mapping->
host;
254 return err ? : copied;
259 loff_t
offset,
unsigned long nr_segs)
261 struct file *file = iocb->
ki_filp;
262 struct inode *inode = file->
f_mapping->host;
269 size = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
277 loff_t isize = i_size_read(inode);
278 loff_t
end = offset + iov_length(iov, nr_segs);
288 .writepage = nilfs_writepage,
289 .readpage = nilfs_readpage,
290 .writepages = nilfs_writepages,
291 .set_page_dirty = nilfs_set_page_dirty,
292 .readpages = nilfs_readpages,
293 .write_begin = nilfs_write_begin,
294 .write_end = nilfs_write_end,
297 .direct_IO = nilfs_direct_IO,
318 root = NILFS_I(dir)->i_root;
325 goto failed_ifile_create_inode;
342 ii->
i_flags = nilfs_mask_flags(
352 insert_inode_hash(inode);
354 err = nilfs_init_acl(inode, dir);
369 failed_ifile_create_inode:
379 unsigned int flags = NILFS_I(inode)->i_flags;
420 ii->i_file_acl =
le32_to_cpu(raw_inode->i_file_acl);
443 struct buffer_head *bh;
452 raw_inode = nilfs_ifile_map_inode(root->
ifile, ino, bh);
473 huge_decode_dev(
le64_to_cpu(raw_inode->i_device_code)));
475 nilfs_ifile_unmap_inode(root->
ifile, ino, bh);
482 nilfs_ifile_unmap_inode(root->
ifile, ino, bh);
490 static int nilfs_iget_test(
struct inode *inode,
void *opaque)
505 static int nilfs_iget_set(
struct inode *inode,
void *opaque)
512 NILFS_I(inode)->i_cno = args->
cno;
513 NILFS_I(inode)->i_root =
NULL;
516 nilfs_get_root(args->
root);
517 NILFS_I(inode)->i_root = args->
root;
526 .
ino =
ino, .root =
root, .cno = 0, .for_gc = 0
529 return ilookup5(sb, ino, nilfs_iget_test, &args);
536 .
ino =
ino, .root =
root, .cno = 0, .for_gc = 0
539 return iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args);
554 err = __nilfs_read_inode(sb, root, ino, inode);
572 inode =
iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args);
611 raw_inode->
i_pad = 0;
612 memset((
void *)raw_inode +
sizeof(*raw_inode), 0,
619 raw_inode->i_device_code =
629 struct inode *ifile = ii->
i_root->ifile;
632 raw_inode = nilfs_ifile_map_inode(ifile, ino, ibh);
635 memset(raw_inode, 0, NILFS_MDT(ifile)->mi_entry_size);
642 nilfs_ifile_unmap_inode(ifile, ino, ibh);
645 #define NILFS_MAX_TRUNCATE_BLOCKS 16384
668 if (!ret || (ret == -
ENOMEM &&
674 "failed to truncate bmap (ino=%lu, err=%d)",
680 unsigned long blkoff;
681 unsigned int blocksize;
697 nilfs_truncate_bmap(ii, blkoff);
710 static void nilfs_clear_inode(
struct inode *inode)
742 if (inode->
i_data.nrpages)
745 nilfs_clear_inode(inode);
750 if (inode->
i_data.nrpages)
754 nilfs_truncate_bmap(ii, 0);
762 nilfs_clear_inode(inode);
774 struct inode *inode = dentry->
d_inode;
787 iattr->
ia_size != i_size_read(inode)) {
796 mark_inode_dirty(inode);
799 err = nilfs_acl_chmod(inode);
813 struct nilfs_root *root = NILFS_I(inode)->i_root;
855 if (!list_empty(&ii->
i_dirty)) {
883 "cannot get inode (ino=%lu)\n",
898 struct buffer_head *ibh;
904 "failed to reget inode block.\n");
909 nilfs_mdt_mark_dirty(NILFS_I(inode)->i_root->ifile);
931 "tried to mark bad_inode dirty. ignored.\n");
936 nilfs_mdt_mark_dirty(inode);
953 unsigned long delalloc_blklen;
963 isize = i_size_read(inode);
965 blkoff = start >> blkbits;
966 end_blkoff = (start + len - 1) >> blkbits;
973 unsigned int maxblocks;
975 if (delalloc_blklen && blkoff == delalloc_blkoff) {
979 fieinfo, logical,
phys, size, flags);
983 if (blkoff > end_blkoff)
987 logical = blkoff << blkbits;
989 size = delalloc_blklen << blkbits;
991 blkoff = delalloc_blkoff + delalloc_blklen;
993 inode, blkoff, &delalloc_blkoff);
1002 if (delalloc_blklen)
1009 NILFS_I(inode)->i_bmap, blkoff, &blkphy, maxblocks);
1020 past_eof = ((blkoff << blkbits) >= isize);
1029 fieinfo, logical,
phys, size, flags);
1034 if (blkoff > end_blkoff || past_eof)
1038 if (
phys && blkphy << blkbits ==
phys + size) {
1040 size += n << blkbits;
1044 fieinfo, logical,
phys, size,
1046 if (ret || blkoff > end_blkoff)
1051 logical = blkoff << blkbits;
1052 phys = blkphy << blkbits;
1053 size = n << blkbits;
1058 logical = blkoff << blkbits;
1059 phys = blkphy << blkbits;
1060 size = n << blkbits;