diff options
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r-- | fs/hugetlbfs/inode.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index a4e9a7ec3691..b14be3f781c7 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/statfs.h> | 31 | #include <linux/statfs.h> |
32 | #include <linux/security.h> | 32 | #include <linux/security.h> |
33 | #include <linux/magic.h> | 33 | #include <linux/magic.h> |
34 | #include <linux/migrate.h> | ||
34 | 35 | ||
35 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
36 | 37 | ||
@@ -371,27 +372,10 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart) | |||
371 | hugetlb_unreserve_pages(inode, start, freed); | 372 | hugetlb_unreserve_pages(inode, start, freed); |
372 | } | 373 | } |
373 | 374 | ||
374 | static void hugetlbfs_delete_inode(struct inode *inode) | 375 | static void hugetlbfs_evict_inode(struct inode *inode) |
375 | { | 376 | { |
376 | truncate_hugepages(inode, 0); | 377 | truncate_hugepages(inode, 0); |
377 | clear_inode(inode); | 378 | end_writeback(inode); |
378 | } | ||
379 | |||
380 | static void hugetlbfs_forget_inode(struct inode *inode) __releases(inode_lock) | ||
381 | { | ||
382 | if (generic_detach_inode(inode)) { | ||
383 | truncate_hugepages(inode, 0); | ||
384 | clear_inode(inode); | ||
385 | destroy_inode(inode); | ||
386 | } | ||
387 | } | ||
388 | |||
389 | static void hugetlbfs_drop_inode(struct inode *inode) | ||
390 | { | ||
391 | if (!inode->i_nlink) | ||
392 | generic_delete_inode(inode); | ||
393 | else | ||
394 | hugetlbfs_forget_inode(inode); | ||
395 | } | 379 | } |
396 | 380 | ||
397 | static inline void | 381 | static inline void |
@@ -448,19 +432,20 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
448 | 432 | ||
449 | error = inode_change_ok(inode, attr); | 433 | error = inode_change_ok(inode, attr); |
450 | if (error) | 434 | if (error) |
451 | goto out; | 435 | return error; |
452 | 436 | ||
453 | if (ia_valid & ATTR_SIZE) { | 437 | if (ia_valid & ATTR_SIZE) { |
454 | error = -EINVAL; | 438 | error = -EINVAL; |
455 | if (!(attr->ia_size & ~huge_page_mask(h))) | 439 | if (attr->ia_size & ~huge_page_mask(h)) |
456 | error = hugetlb_vmtruncate(inode, attr->ia_size); | 440 | return -EINVAL; |
441 | error = hugetlb_vmtruncate(inode, attr->ia_size); | ||
457 | if (error) | 442 | if (error) |
458 | goto out; | 443 | return error; |
459 | attr->ia_valid &= ~ATTR_SIZE; | ||
460 | } | 444 | } |
461 | error = inode_setattr(inode, attr); | 445 | |
462 | out: | 446 | setattr_copy(inode, attr); |
463 | return error; | 447 | mark_inode_dirty(inode); |
448 | return 0; | ||
464 | } | 449 | } |
465 | 450 | ||
466 | static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | 451 | static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, |
@@ -471,6 +456,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | |||
471 | inode = new_inode(sb); | 456 | inode = new_inode(sb); |
472 | if (inode) { | 457 | if (inode) { |
473 | struct hugetlbfs_inode_info *info; | 458 | struct hugetlbfs_inode_info *info; |
459 | inode->i_ino = get_next_ino(); | ||
474 | inode->i_mode = mode; | 460 | inode->i_mode = mode; |
475 | inode->i_uid = uid; | 461 | inode->i_uid = uid; |
476 | inode->i_gid = gid; | 462 | inode->i_gid = gid; |
@@ -589,6 +575,19 @@ static int hugetlbfs_set_page_dirty(struct page *page) | |||
589 | return 0; | 575 | return 0; |
590 | } | 576 | } |
591 | 577 | ||
578 | static int hugetlbfs_migrate_page(struct address_space *mapping, | ||
579 | struct page *newpage, struct page *page) | ||
580 | { | ||
581 | int rc; | ||
582 | |||
583 | rc = migrate_huge_page_move_mapping(mapping, newpage, page); | ||
584 | if (rc) | ||
585 | return rc; | ||
586 | migrate_page_copy(newpage, page); | ||
587 | |||
588 | return 0; | ||
589 | } | ||
590 | |||
592 | static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 591 | static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
593 | { | 592 | { |
594 | struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); | 593 | struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); |
@@ -675,6 +674,7 @@ static const struct address_space_operations hugetlbfs_aops = { | |||
675 | .write_begin = hugetlbfs_write_begin, | 674 | .write_begin = hugetlbfs_write_begin, |
676 | .write_end = hugetlbfs_write_end, | 675 | .write_end = hugetlbfs_write_end, |
677 | .set_page_dirty = hugetlbfs_set_page_dirty, | 676 | .set_page_dirty = hugetlbfs_set_page_dirty, |
677 | .migratepage = hugetlbfs_migrate_page, | ||
678 | }; | 678 | }; |
679 | 679 | ||
680 | 680 | ||
@@ -690,6 +690,7 @@ const struct file_operations hugetlbfs_file_operations = { | |||
690 | .mmap = hugetlbfs_file_mmap, | 690 | .mmap = hugetlbfs_file_mmap, |
691 | .fsync = noop_fsync, | 691 | .fsync = noop_fsync, |
692 | .get_unmapped_area = hugetlb_get_unmapped_area, | 692 | .get_unmapped_area = hugetlb_get_unmapped_area, |
693 | .llseek = default_llseek, | ||
693 | }; | 694 | }; |
694 | 695 | ||
695 | static const struct inode_operations hugetlbfs_dir_inode_operations = { | 696 | static const struct inode_operations hugetlbfs_dir_inode_operations = { |
@@ -712,9 +713,8 @@ static const struct inode_operations hugetlbfs_inode_operations = { | |||
712 | static const struct super_operations hugetlbfs_ops = { | 713 | static const struct super_operations hugetlbfs_ops = { |
713 | .alloc_inode = hugetlbfs_alloc_inode, | 714 | .alloc_inode = hugetlbfs_alloc_inode, |
714 | .destroy_inode = hugetlbfs_destroy_inode, | 715 | .destroy_inode = hugetlbfs_destroy_inode, |
716 | .evict_inode = hugetlbfs_evict_inode, | ||
715 | .statfs = hugetlbfs_statfs, | 717 | .statfs = hugetlbfs_statfs, |
716 | .delete_inode = hugetlbfs_delete_inode, | ||
717 | .drop_inode = hugetlbfs_drop_inode, | ||
718 | .put_super = hugetlbfs_put_super, | 718 | .put_super = hugetlbfs_put_super, |
719 | .show_options = generic_show_options, | 719 | .show_options = generic_show_options, |
720 | }; | 720 | }; |