2 * inode.c - NILFS inode operations.
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Written by Ryusuke Konishi <ryusuke@osrg.net>
24 #include <linux/buffer_head.h>
25 #include <linux/mpage.h>
26 #include <linux/writeback.h>
27 #include <linux/uio.h>
37 * nilfs_get_block() - get a file block on the filesystem (callback function)
38 * @inode - inode struct of the target file
39 * @blkoff - file block number
40 * @bh_result - buffer head to be mapped on
41 * @create - indicate whether allocating the block or not when it has not
44 * This function does not issue actual read request of the specified data
45 * block. It is done by VFS.
46 * Bulk read for direct-io is not supported yet. (should be supported)
48 int nilfs_get_block(struct inode *inode, sector_t blkoff,
49 struct buffer_head *bh_result, int create)
51 struct nilfs_inode_info *ii = NILFS_I(inode);
52 unsigned long blknum = 0;
54 struct inode *dat = nilfs_dat_inode(NILFS_I_NILFS(inode));
56 /* This exclusion control is a workaround; should be revised */
57 down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
58 ret = nilfs_bmap_lookup(ii->i_bmap, (unsigned long)blkoff, &blknum);
59 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
60 if (ret == 0) { /* found */
61 map_bh(bh_result, inode->i_sb, blknum);
64 /* data block was not found */
65 if (ret == -ENOENT && create) {
66 struct nilfs_transaction_info ti;
68 bh_result->b_blocknr = 0;
69 err = nilfs_transaction_begin(inode->i_sb, &ti, 1);
72 err = nilfs_bmap_insert(ii->i_bmap, (unsigned long)blkoff,
73 (unsigned long)bh_result);
74 if (unlikely(err != 0)) {
77 * The get_block() function could be called
78 * from multiple callers for an inode.
79 * However, the page having this block must
80 * be locked in this case.
83 "nilfs_get_block: a race condition "
84 "while inserting a data block. "
85 "(inode number=%lu, file block "
88 (unsigned long long)blkoff);
90 } else if (err == -EINVAL) {
91 nilfs_error(inode->i_sb, __func__,
92 "broken bmap (inode=%lu)\n",
96 nilfs_transaction_abort(inode->i_sb);
99 nilfs_transaction_commit(inode->i_sb); /* never fails */
100 /* Error handling should be detailed */
101 set_buffer_new(bh_result);
102 map_bh(bh_result, inode->i_sb, 0); /* dbn must be changed
104 } else if (ret == -ENOENT) {
105 /* not found is not error (e.g. hole); must return without
106 the mapped state flag. */
117 * nilfs_readpage() - implement readpage() method of nilfs_aops {}
118 * address_space_operations.
119 * @file - file struct of the file to be read
120 * @page - the page to be read
122 static int nilfs_readpage(struct file *file, struct page *page)
124 return mpage_readpage(page, nilfs_get_block);
128 * nilfs_readpages() - implement readpages() method of nilfs_aops {}
129 * address_space_operations.
130 * @file - file struct of the file to be read
131 * @mapping - address_space struct used for reading multiple pages
132 * @pages - the pages to be read
133 * @nr_pages - number of pages to be read
135 static int nilfs_readpages(struct file *file, struct address_space *mapping,
136 struct list_head *pages, unsigned nr_pages)
138 return mpage_readpages(mapping, pages, nr_pages, nilfs_get_block);
141 static int nilfs_writepages(struct address_space *mapping,
142 struct writeback_control *wbc)
144 struct inode *inode = mapping->host;
147 if (wbc->sync_mode == WB_SYNC_ALL)
148 err = nilfs_construct_dsync_segment(inode->i_sb, inode,
154 static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
156 struct inode *inode = page->mapping->host;
159 redirty_page_for_writepage(wbc, page);
162 if (wbc->sync_mode == WB_SYNC_ALL) {
163 err = nilfs_construct_segment(inode->i_sb);
166 } else if (wbc->for_reclaim)
167 nilfs_flush_segment(inode->i_sb, inode->i_ino);
172 static int nilfs_set_page_dirty(struct page *page)
174 int ret = __set_page_dirty_buffers(page);
177 struct inode *inode = page->mapping->host;
178 struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
179 unsigned nr_dirty = 1 << (PAGE_SHIFT - inode->i_blkbits);
181 nilfs_set_file_dirty(sbi, inode, nr_dirty);
186 static int nilfs_write_begin(struct file *file, struct address_space *mapping,
187 loff_t pos, unsigned len, unsigned flags,
188 struct page **pagep, void **fsdata)
191 struct inode *inode = mapping->host;
192 int err = nilfs_transaction_begin(inode->i_sb, NULL, 1);
198 err = block_write_begin(file, mapping, pos, len, flags, pagep,
199 fsdata, nilfs_get_block);
201 nilfs_transaction_abort(inode->i_sb);
205 static int nilfs_write_end(struct file *file, struct address_space *mapping,
206 loff_t pos, unsigned len, unsigned copied,
207 struct page *page, void *fsdata)
209 struct inode *inode = mapping->host;
210 unsigned start = pos & (PAGE_CACHE_SIZE - 1);
214 nr_dirty = nilfs_page_count_clean_buffers(page, start,
216 copied = generic_write_end(file, mapping, pos, len, copied, page,
218 nilfs_set_file_dirty(NILFS_SB(inode->i_sb), inode, nr_dirty);
219 err = nilfs_transaction_commit(inode->i_sb);
220 return err ? : copied;
224 nilfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
225 loff_t offset, unsigned long nr_segs)
227 struct file *file = iocb->ki_filp;
228 struct inode *inode = file->f_mapping->host;
234 /* Needs synchronization with the cleaner */
235 size = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
236 offset, nr_segs, nilfs_get_block, NULL);
240 struct address_space_operations nilfs_aops = {
241 .writepage = nilfs_writepage,
242 .readpage = nilfs_readpage,
243 /* .sync_page = nilfs_sync_page, */
244 .writepages = nilfs_writepages,
245 .set_page_dirty = nilfs_set_page_dirty,
246 .readpages = nilfs_readpages,
247 .write_begin = nilfs_write_begin,
248 .write_end = nilfs_write_end,
249 /* .releasepage = nilfs_releasepage, */
250 .invalidatepage = block_invalidatepage,
251 .direct_IO = nilfs_direct_IO,
254 struct inode *nilfs_new_inode(struct inode *dir, int mode)
256 struct super_block *sb = dir->i_sb;
257 struct nilfs_sb_info *sbi = NILFS_SB(sb);
259 struct nilfs_inode_info *ii;
263 inode = new_inode(sb);
264 if (unlikely(!inode))
267 mapping_set_gfp_mask(inode->i_mapping,
268 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
271 ii->i_state = 1 << NILFS_I_NEW;
273 err = nilfs_ifile_create_inode(sbi->s_ifile, &ino, &ii->i_bh);
275 goto failed_ifile_create_inode;
276 /* reference count of i_bh inherits from nilfs_mdt_read_block() */
278 atomic_inc(&sbi->s_inodes_count);
280 inode->i_uid = current_fsuid();
281 if (dir->i_mode & S_ISGID) {
282 inode->i_gid = dir->i_gid;
286 inode->i_gid = current_fsgid();
288 inode->i_mode = mode;
290 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
292 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
293 err = nilfs_bmap_read(ii->i_bmap, NULL);
297 set_bit(NILFS_I_BMAP, &ii->i_state);
298 /* No lock is needed; iget() ensures it. */
301 ii->i_flags = NILFS_I(dir)->i_flags;
303 ii->i_flags &= ~(NILFS_IMMUTABLE_FL | NILFS_APPEND_FL);
305 ii->i_flags &= ~NILFS_DIRSYNC_FL;
307 /* ii->i_file_acl = 0; */
308 /* ii->i_dir_acl = 0; */
310 ii->i_dir_start_lookup = 0;
311 #ifdef CONFIG_NILFS_FS_POSIX_ACL
313 ii->i_default_acl = NULL;
316 nilfs_set_inode_flags(inode);
317 spin_lock(&sbi->s_next_gen_lock);
318 inode->i_generation = sbi->s_next_generation++;
319 spin_unlock(&sbi->s_next_gen_lock);
320 insert_inode_hash(inode);
322 err = nilfs_init_acl(inode, dir);
324 goto failed_acl; /* never occur. When supporting
325 nilfs_init_acl(), proper cancellation of
326 above jobs should be considered */
328 mark_inode_dirty(inode);
334 iput(inode); /* raw_inode will be deleted through
335 generic_delete_inode() */
338 failed_ifile_create_inode:
339 make_bad_inode(inode);
340 iput(inode); /* if i_nlink == 1, generic_forget_inode() will be
346 void nilfs_free_inode(struct inode *inode)
348 struct super_block *sb = inode->i_sb;
349 struct nilfs_sb_info *sbi = NILFS_SB(sb);
352 /* XXX: check error code? Is there any thing I can do? */
353 (void) nilfs_ifile_delete_inode(sbi->s_ifile, inode->i_ino);
354 atomic_dec(&sbi->s_inodes_count);
357 void nilfs_set_inode_flags(struct inode *inode)
359 unsigned int flags = NILFS_I(inode)->i_flags;
361 inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME |
363 if (flags & NILFS_SYNC_FL)
364 inode->i_flags |= S_SYNC;
365 if (flags & NILFS_APPEND_FL)
366 inode->i_flags |= S_APPEND;
367 if (flags & NILFS_IMMUTABLE_FL)
368 inode->i_flags |= S_IMMUTABLE;
369 #ifndef NILFS_ATIME_DISABLE
370 if (flags & NILFS_NOATIME_FL)
372 inode->i_flags |= S_NOATIME;
373 if (flags & NILFS_DIRSYNC_FL)
374 inode->i_flags |= S_DIRSYNC;
375 mapping_set_gfp_mask(inode->i_mapping,
376 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
379 int nilfs_read_inode_common(struct inode *inode,
380 struct nilfs_inode *raw_inode)
382 struct nilfs_inode_info *ii = NILFS_I(inode);
385 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
386 inode->i_uid = (uid_t)le32_to_cpu(raw_inode->i_uid);
387 inode->i_gid = (gid_t)le32_to_cpu(raw_inode->i_gid);
388 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
389 inode->i_size = le64_to_cpu(raw_inode->i_size);
390 inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
391 inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
392 inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
393 inode->i_atime.tv_nsec = 0;
394 inode->i_ctime.tv_nsec = 0;
395 inode->i_mtime.tv_nsec = 0;
396 ii->i_dtime = le64_to_cpu(raw_inode->i_dtime);
397 if (inode->i_nlink == 0 && (inode->i_mode == 0 || ii->i_dtime))
398 return -EINVAL; /* this inode is deleted */
400 inode->i_blocks = le64_to_cpu(raw_inode->i_blocks);
401 ii->i_flags = le32_to_cpu(raw_inode->i_flags);
403 ii->i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
404 ii->i_dir_acl = S_ISREG(inode->i_mode) ?
405 0 : le32_to_cpu(raw_inode->i_dir_acl);
408 inode->i_generation = le32_to_cpu(raw_inode->i_generation);
410 if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
411 S_ISLNK(inode->i_mode)) {
412 err = nilfs_bmap_read(ii->i_bmap, raw_inode);
415 set_bit(NILFS_I_BMAP, &ii->i_state);
416 /* No lock is needed; iget() ensures it. */
421 static int __nilfs_read_inode(struct super_block *sb, unsigned long ino,
424 struct nilfs_sb_info *sbi = NILFS_SB(sb);
425 struct inode *dat = nilfs_dat_inode(sbi->s_nilfs);
426 struct buffer_head *bh;
427 struct nilfs_inode *raw_inode;
430 down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
431 err = nilfs_ifile_get_inode_block(sbi->s_ifile, ino, &bh);
435 raw_inode = nilfs_ifile_map_inode(sbi->s_ifile, ino, bh);
437 #ifdef CONFIG_NILFS_FS_POSIX_ACL
438 ii->i_acl = NILFS_ACL_NOT_CACHED;
439 ii->i_default_acl = NILFS_ACL_NOT_CACHED;
441 if (nilfs_read_inode_common(inode, raw_inode))
444 if (S_ISREG(inode->i_mode)) {
445 inode->i_op = &nilfs_file_inode_operations;
446 inode->i_fop = &nilfs_file_operations;
447 inode->i_mapping->a_ops = &nilfs_aops;
448 } else if (S_ISDIR(inode->i_mode)) {
449 inode->i_op = &nilfs_dir_inode_operations;
450 inode->i_fop = &nilfs_dir_operations;
451 inode->i_mapping->a_ops = &nilfs_aops;
452 } else if (S_ISLNK(inode->i_mode)) {
453 inode->i_op = &nilfs_symlink_inode_operations;
454 inode->i_mapping->a_ops = &nilfs_aops;
456 inode->i_op = &nilfs_special_inode_operations;
458 inode, inode->i_mode,
459 new_decode_dev(le64_to_cpu(raw_inode->i_device_code)));
461 nilfs_ifile_unmap_inode(sbi->s_ifile, ino, bh);
463 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
464 nilfs_set_inode_flags(inode);
468 nilfs_ifile_unmap_inode(sbi->s_ifile, ino, bh);
472 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
476 struct inode *nilfs_iget(struct super_block *sb, unsigned long ino)
481 inode = iget_locked(sb, ino);
482 if (unlikely(!inode))
483 return ERR_PTR(-ENOMEM);
484 if (!(inode->i_state & I_NEW))
487 err = __nilfs_read_inode(sb, ino, inode);
492 unlock_new_inode(inode);
496 void nilfs_write_inode_common(struct inode *inode,
497 struct nilfs_inode *raw_inode, int has_bmap)
499 struct nilfs_inode_info *ii = NILFS_I(inode);
501 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
502 raw_inode->i_uid = cpu_to_le32(inode->i_uid);
503 raw_inode->i_gid = cpu_to_le32(inode->i_gid);
504 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
505 raw_inode->i_size = cpu_to_le64(inode->i_size);
506 raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
507 raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
508 raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
510 raw_inode->i_dtime = cpu_to_le64(ii->i_dtime);
511 raw_inode->i_flags = cpu_to_le32(ii->i_flags);
512 raw_inode->i_generation = cpu_to_le32(inode->i_generation);
515 nilfs_bmap_write(ii->i_bmap, raw_inode);
516 else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
517 raw_inode->i_device_code =
518 cpu_to_le64(new_encode_dev(inode->i_rdev));
519 /* When extending inode, nilfs->ns_inode_size should be checked
520 for substitutions of appended fields */
523 void nilfs_update_inode(struct inode *inode, struct buffer_head *ibh)
525 ino_t ino = inode->i_ino;
526 struct nilfs_inode_info *ii = NILFS_I(inode);
527 struct super_block *sb = inode->i_sb;
528 struct nilfs_sb_info *sbi = NILFS_SB(sb);
529 struct nilfs_inode *raw_inode;
531 raw_inode = nilfs_ifile_map_inode(sbi->s_ifile, ino, ibh);
533 /* The buffer is guarded with lock_buffer() by the caller */
534 if (test_and_clear_bit(NILFS_I_NEW, &ii->i_state))
535 memset(raw_inode, 0, NILFS_MDT(sbi->s_ifile)->mi_entry_size);
536 set_bit(NILFS_I_INODE_DIRTY, &ii->i_state);
538 nilfs_write_inode_common(inode, raw_inode, 0);
539 /* XXX: call with has_bmap = 0 is a workaround to avoid
540 deadlock of bmap. This delays update of i_bmap to just
542 nilfs_ifile_unmap_inode(sbi->s_ifile, ino, ibh);
545 #define NILFS_MAX_TRUNCATE_BLOCKS 16384 /* 64MB for 4KB block */
547 static void nilfs_truncate_bmap(struct nilfs_inode_info *ii,
553 if (!test_bit(NILFS_I_BMAP, &ii->i_state))
556 ret = nilfs_bmap_last_key(ii->i_bmap, &b);
565 b -= min_t(unsigned long, NILFS_MAX_TRUNCATE_BLOCKS, b - from);
566 ret = nilfs_bmap_truncate(ii->i_bmap, b);
567 nilfs_relax_pressure_in_lock(ii->vfs_inode.i_sb);
568 if (!ret || (ret == -ENOMEM &&
569 nilfs_bmap_truncate(ii->i_bmap, b) == 0))
574 nilfs_error(ii->vfs_inode.i_sb, __func__,
575 "bmap is broken (ino=%lu)", ii->vfs_inode.i_ino);
577 nilfs_warning(ii->vfs_inode.i_sb, __func__,
578 "failed to truncate bmap (ino=%lu, err=%d)",
579 ii->vfs_inode.i_ino, ret);
582 void nilfs_truncate(struct inode *inode)
584 unsigned long blkoff;
585 unsigned int blocksize;
586 struct nilfs_transaction_info ti;
587 struct super_block *sb = inode->i_sb;
588 struct nilfs_inode_info *ii = NILFS_I(inode);
590 if (!test_bit(NILFS_I_BMAP, &ii->i_state))
592 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
595 blocksize = sb->s_blocksize;
596 blkoff = (inode->i_size + blocksize - 1) >> sb->s_blocksize_bits;
597 nilfs_transaction_begin(sb, &ti, 0); /* never fails */
599 block_truncate_page(inode->i_mapping, inode->i_size, nilfs_get_block);
601 nilfs_truncate_bmap(ii, blkoff);
603 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
605 nilfs_set_transaction_flag(NILFS_TI_SYNC);
607 nilfs_set_file_dirty(NILFS_SB(sb), inode, 0);
608 nilfs_transaction_commit(sb);
609 /* May construct a logical segment and may fail in sync mode.
610 But truncate has no return value. */
613 void nilfs_delete_inode(struct inode *inode)
615 struct nilfs_transaction_info ti;
616 struct super_block *sb = inode->i_sb;
617 struct nilfs_inode_info *ii = NILFS_I(inode);
619 if (unlikely(is_bad_inode(inode))) {
620 if (inode->i_data.nrpages)
621 truncate_inode_pages(&inode->i_data, 0);
625 nilfs_transaction_begin(sb, &ti, 0); /* never fails */
627 if (inode->i_data.nrpages)
628 truncate_inode_pages(&inode->i_data, 0);
630 nilfs_truncate_bmap(ii, 0);
631 nilfs_free_inode(inode);
632 /* nilfs_free_inode() marks inode buffer dirty */
634 nilfs_set_transaction_flag(NILFS_TI_SYNC);
635 nilfs_transaction_commit(sb);
636 /* May construct a logical segment and may fail in sync mode.
637 But delete_inode has no return value. */
640 int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)
642 struct nilfs_transaction_info ti;
643 struct inode *inode = dentry->d_inode;
644 struct super_block *sb = inode->i_sb;
647 err = inode_change_ok(inode, iattr);
651 err = nilfs_transaction_begin(sb, &ti, 0);
654 err = inode_setattr(inode, iattr);
655 if (!err && (iattr->ia_valid & ATTR_MODE))
656 err = nilfs_acl_chmod(inode);
658 err = nilfs_transaction_commit(sb);
660 nilfs_transaction_abort(sb);
665 int nilfs_load_inode_block(struct nilfs_sb_info *sbi, struct inode *inode,
666 struct buffer_head **pbh)
668 struct nilfs_inode_info *ii = NILFS_I(inode);
671 spin_lock(&sbi->s_inode_lock);
672 /* Caller of this function MUST lock s_inode_lock */
673 if (ii->i_bh == NULL) {
674 spin_unlock(&sbi->s_inode_lock);
675 err = nilfs_ifile_get_inode_block(sbi->s_ifile, inode->i_ino,
679 spin_lock(&sbi->s_inode_lock);
680 if (ii->i_bh == NULL)
690 spin_unlock(&sbi->s_inode_lock);
694 int nilfs_inode_dirty(struct inode *inode)
696 struct nilfs_inode_info *ii = NILFS_I(inode);
697 struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
700 if (!list_empty(&ii->i_dirty)) {
701 spin_lock(&sbi->s_inode_lock);
702 ret = test_bit(NILFS_I_DIRTY, &ii->i_state) ||
703 test_bit(NILFS_I_BUSY, &ii->i_state);
704 spin_unlock(&sbi->s_inode_lock);
709 int nilfs_set_file_dirty(struct nilfs_sb_info *sbi, struct inode *inode,
712 struct nilfs_inode_info *ii = NILFS_I(inode);
714 atomic_add(nr_dirty, &sbi->s_nilfs->ns_ndirtyblks);
716 if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state))
719 spin_lock(&sbi->s_inode_lock);
720 if (!test_bit(NILFS_I_QUEUED, &ii->i_state) &&
721 !test_bit(NILFS_I_BUSY, &ii->i_state)) {
722 /* Because this routine may race with nilfs_dispose_list(),
723 we have to check NILFS_I_QUEUED here, too. */
724 if (list_empty(&ii->i_dirty) && igrab(inode) == NULL) {
725 /* This will happen when somebody is freeing
727 nilfs_warning(sbi->s_super, __func__,
728 "cannot get inode (ino=%lu)\n",
730 spin_unlock(&sbi->s_inode_lock);
731 return -EINVAL; /* NILFS_I_DIRTY may remain for
734 list_del(&ii->i_dirty);
735 list_add_tail(&ii->i_dirty, &sbi->s_dirty_files);
736 set_bit(NILFS_I_QUEUED, &ii->i_state);
738 spin_unlock(&sbi->s_inode_lock);
742 int nilfs_mark_inode_dirty(struct inode *inode)
744 struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
745 struct buffer_head *ibh;
748 err = nilfs_load_inode_block(sbi, inode, &ibh);
750 nilfs_warning(inode->i_sb, __func__,
751 "failed to reget inode block.\n");
755 nilfs_update_inode(inode, ibh);
757 nilfs_mdt_mark_buffer_dirty(ibh);
758 nilfs_mdt_mark_dirty(sbi->s_ifile);
764 * nilfs_dirty_inode - reflect changes on given inode to an inode block.
765 * @inode: inode of the file to be registered.
767 * nilfs_dirty_inode() loads a inode block containing the specified
768 * @inode and copies data from a nilfs_inode to a corresponding inode
769 * entry in the inode block. This operation is excluded from the segment
770 * construction. This function can be called both as a single operation
771 * and as a part of indivisible file operations.
773 void nilfs_dirty_inode(struct inode *inode)
775 struct nilfs_transaction_info ti;
777 if (is_bad_inode(inode)) {
778 nilfs_warning(inode->i_sb, __func__,
779 "tried to mark bad_inode dirty. ignored.\n");
783 nilfs_transaction_begin(inode->i_sb, &ti, 0);
784 nilfs_mark_inode_dirty(inode);
785 nilfs_transaction_commit(inode->i_sb); /* never fails */