diff options
Diffstat (limited to 'fs')
55 files changed, 599 insertions, 541 deletions
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 5f8ab8adb5f..ab5547ff29a 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include <linux/mount.h> | 37 | #include <linux/mount.h> |
| 38 | #include <linux/idr.h> | 38 | #include <linux/idr.h> |
| 39 | #include <linux/sched.h> | 39 | #include <linux/sched.h> |
| 40 | #include <linux/smp_lock.h> | ||
| 40 | #include <net/9p/9p.h> | 41 | #include <net/9p/9p.h> |
| 41 | #include <net/9p/client.h> | 42 | #include <net/9p/client.h> |
| 42 | 43 | ||
| @@ -155,6 +156,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 155 | 156 | ||
| 156 | root = d_alloc_root(inode); | 157 | root = d_alloc_root(inode); |
| 157 | if (!root) { | 158 | if (!root) { |
| 159 | iput(inode); | ||
| 158 | retval = -ENOMEM; | 160 | retval = -ENOMEM; |
| 159 | goto release_sb; | 161 | goto release_sb; |
| 160 | } | 162 | } |
| @@ -173,10 +175,7 @@ P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n"); | |||
| 173 | return 0; | 175 | return 0; |
| 174 | 176 | ||
| 175 | release_sb: | 177 | release_sb: |
| 176 | if (sb) { | 178 | deactivate_locked_super(sb); |
| 177 | up_write(&sb->s_umount); | ||
| 178 | deactivate_super(sb); | ||
| 179 | } | ||
| 180 | 179 | ||
| 181 | free_stat: | 180 | free_stat: |
| 182 | kfree(st); | 181 | kfree(st); |
| @@ -230,9 +229,12 @@ static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
| 230 | static void | 229 | static void |
| 231 | v9fs_umount_begin(struct super_block *sb) | 230 | v9fs_umount_begin(struct super_block *sb) |
| 232 | { | 231 | { |
| 233 | struct v9fs_session_info *v9ses = sb->s_fs_info; | 232 | struct v9fs_session_info *v9ses; |
| 234 | 233 | ||
| 234 | lock_kernel(); | ||
| 235 | v9ses = sb->s_fs_info; | ||
| 235 | v9fs_session_cancel(v9ses); | 236 | v9fs_session_cancel(v9ses); |
| 237 | unlock_kernel(); | ||
| 236 | } | 238 | } |
| 237 | 239 | ||
| 238 | static const struct super_operations v9fs_super_ops = { | 240 | static const struct super_operations v9fs_super_ops = { |
diff --git a/fs/affs/super.c b/fs/affs/super.c index 5ce695e707f..63f5183f263 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
| @@ -507,8 +507,7 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
| 507 | kfree(new_opts); | 507 | kfree(new_opts); |
| 508 | return -EINVAL; | 508 | return -EINVAL; |
| 509 | } | 509 | } |
| 510 | kfree(sb->s_options); | 510 | replace_mount_options(sb, new_opts); |
| 511 | sb->s_options = new_opts; | ||
| 512 | 511 | ||
| 513 | sbi->s_flags = mount_flags; | 512 | sbi->s_flags = mount_flags; |
| 514 | sbi->s_mode = mode; | 513 | sbi->s_mode = mode; |
diff --git a/fs/afs/super.c b/fs/afs/super.c index aee239a048c..76828e5f8a3 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c | |||
| @@ -405,21 +405,20 @@ static int afs_get_sb(struct file_system_type *fs_type, | |||
| 405 | sb->s_flags = flags; | 405 | sb->s_flags = flags; |
| 406 | ret = afs_fill_super(sb, ¶ms); | 406 | ret = afs_fill_super(sb, ¶ms); |
| 407 | if (ret < 0) { | 407 | if (ret < 0) { |
| 408 | up_write(&sb->s_umount); | 408 | deactivate_locked_super(sb); |
| 409 | deactivate_super(sb); | ||
| 410 | goto error; | 409 | goto error; |
| 411 | } | 410 | } |
| 412 | sb->s_options = new_opts; | 411 | save_mount_options(sb, new_opts); |
| 413 | sb->s_flags |= MS_ACTIVE; | 412 | sb->s_flags |= MS_ACTIVE; |
| 414 | } else { | 413 | } else { |
| 415 | _debug("reuse"); | 414 | _debug("reuse"); |
| 416 | kfree(new_opts); | ||
| 417 | ASSERTCMP(sb->s_flags, &, MS_ACTIVE); | 415 | ASSERTCMP(sb->s_flags, &, MS_ACTIVE); |
| 418 | } | 416 | } |
| 419 | 417 | ||
| 420 | simple_set_mnt(mnt, sb); | 418 | simple_set_mnt(mnt, sb); |
| 421 | afs_put_volume(params.volume); | 419 | afs_put_volume(params.volume); |
| 422 | afs_put_cell(params.cell); | 420 | afs_put_cell(params.cell); |
| 421 | kfree(new_opts); | ||
| 423 | _leave(" = 0 [%p]", sb); | 422 | _leave(" = 0 [%p]", sb); |
| 424 | return 0; | 423 | return 0; |
| 425 | 424 | ||
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a99f1c2a710..fedf8b9f03a 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
| @@ -1469,6 +1469,7 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
| 1469 | u32 blocksize; | 1469 | u32 blocksize; |
| 1470 | struct extent_buffer *b = *eb_ret; | 1470 | struct extent_buffer *b = *eb_ret; |
| 1471 | struct extent_buffer *tmp; | 1471 | struct extent_buffer *tmp; |
| 1472 | int ret; | ||
| 1472 | 1473 | ||
| 1473 | blocknr = btrfs_node_blockptr(b, slot); | 1474 | blocknr = btrfs_node_blockptr(b, slot); |
| 1474 | gen = btrfs_node_ptr_generation(b, slot); | 1475 | gen = btrfs_node_ptr_generation(b, slot); |
| @@ -1476,6 +1477,10 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
| 1476 | 1477 | ||
| 1477 | tmp = btrfs_find_tree_block(root, blocknr, blocksize); | 1478 | tmp = btrfs_find_tree_block(root, blocknr, blocksize); |
| 1478 | if (tmp && btrfs_buffer_uptodate(tmp, gen)) { | 1479 | if (tmp && btrfs_buffer_uptodate(tmp, gen)) { |
| 1480 | /* | ||
| 1481 | * we found an up to date block without sleeping, return | ||
| 1482 | * right away | ||
| 1483 | */ | ||
| 1479 | *eb_ret = tmp; | 1484 | *eb_ret = tmp; |
| 1480 | return 0; | 1485 | return 0; |
| 1481 | } | 1486 | } |
| @@ -1483,7 +1488,9 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
| 1483 | /* | 1488 | /* |
| 1484 | * reduce lock contention at high levels | 1489 | * reduce lock contention at high levels |
| 1485 | * of the btree by dropping locks before | 1490 | * of the btree by dropping locks before |
| 1486 | * we read. | 1491 | * we read. Don't release the lock on the current |
| 1492 | * level because we need to walk this node to figure | ||
| 1493 | * out which blocks to read. | ||
| 1487 | */ | 1494 | */ |
| 1488 | btrfs_unlock_up_safe(p, level + 1); | 1495 | btrfs_unlock_up_safe(p, level + 1); |
| 1489 | btrfs_set_path_blocking(p); | 1496 | btrfs_set_path_blocking(p); |
| @@ -1494,10 +1501,21 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
| 1494 | reada_for_search(root, p, level, slot, key->objectid); | 1501 | reada_for_search(root, p, level, slot, key->objectid); |
| 1495 | 1502 | ||
| 1496 | btrfs_release_path(NULL, p); | 1503 | btrfs_release_path(NULL, p); |
| 1504 | |||
| 1505 | ret = -EAGAIN; | ||
| 1497 | tmp = read_tree_block(root, blocknr, blocksize, gen); | 1506 | tmp = read_tree_block(root, blocknr, blocksize, gen); |
| 1498 | if (tmp) | 1507 | if (tmp) { |
| 1508 | /* | ||
| 1509 | * If the read above didn't mark this buffer up to date, | ||
| 1510 | * it will never end up being up to date. Set ret to EIO now | ||
| 1511 | * and give up so that our caller doesn't loop forever | ||
| 1512 | * on our EAGAINs. | ||
| 1513 | */ | ||
| 1514 | if (!btrfs_buffer_uptodate(tmp, 0)) | ||
| 1515 | ret = -EIO; | ||
| 1499 | free_extent_buffer(tmp); | 1516 | free_extent_buffer(tmp); |
| 1500 | return -EAGAIN; | 1517 | } |
| 1518 | return ret; | ||
| 1501 | } | 1519 | } |
| 1502 | 1520 | ||
| 1503 | /* | 1521 | /* |
| @@ -1696,6 +1714,9 @@ cow_done: | |||
| 1696 | if (ret == -EAGAIN) | 1714 | if (ret == -EAGAIN) |
| 1697 | goto again; | 1715 | goto again; |
| 1698 | 1716 | ||
| 1717 | if (ret == -EIO) | ||
| 1718 | goto done; | ||
| 1719 | |||
| 1699 | if (!p->skip_locking) { | 1720 | if (!p->skip_locking) { |
| 1700 | int lret; | 1721 | int lret; |
| 1701 | 1722 | ||
| @@ -1738,6 +1759,8 @@ done: | |||
| 1738 | */ | 1759 | */ |
| 1739 | if (!p->leave_spinning) | 1760 | if (!p->leave_spinning) |
| 1740 | btrfs_set_path_blocking(p); | 1761 | btrfs_set_path_blocking(p); |
| 1762 | if (ret < 0) | ||
| 1763 | btrfs_release_path(root, p); | ||
| 1741 | return ret; | 1764 | return ret; |
| 1742 | } | 1765 | } |
| 1743 | 1766 | ||
| @@ -4212,6 +4235,11 @@ again: | |||
| 4212 | if (ret == -EAGAIN) | 4235 | if (ret == -EAGAIN) |
| 4213 | goto again; | 4236 | goto again; |
| 4214 | 4237 | ||
| 4238 | if (ret < 0) { | ||
| 4239 | btrfs_release_path(root, path); | ||
| 4240 | goto done; | ||
| 4241 | } | ||
| 4242 | |||
| 4215 | if (!path->skip_locking) { | 4243 | if (!path->skip_locking) { |
| 4216 | ret = btrfs_try_spin_lock(next); | 4244 | ret = btrfs_try_spin_lock(next); |
| 4217 | if (!ret) { | 4245 | if (!ret) { |
| @@ -4246,6 +4274,11 @@ again: | |||
| 4246 | if (ret == -EAGAIN) | 4274 | if (ret == -EAGAIN) |
| 4247 | goto again; | 4275 | goto again; |
| 4248 | 4276 | ||
| 4277 | if (ret < 0) { | ||
| 4278 | btrfs_release_path(root, path); | ||
| 4279 | goto done; | ||
| 4280 | } | ||
| 4281 | |||
| 4249 | if (!path->skip_locking) { | 4282 | if (!path->skip_locking) { |
| 4250 | btrfs_assert_tree_locked(path->nodes[level]); | 4283 | btrfs_assert_tree_locked(path->nodes[level]); |
| 4251 | ret = btrfs_try_spin_lock(next); | 4284 | ret = btrfs_try_spin_lock(next); |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 0ff16d3331d..4b0ea0b80c2 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
| @@ -848,8 +848,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | |||
| 848 | 848 | ||
| 849 | if (ret == 0) | 849 | if (ret == 0) |
| 850 | set_bit(EXTENT_BUFFER_UPTODATE, &buf->bflags); | 850 | set_bit(EXTENT_BUFFER_UPTODATE, &buf->bflags); |
| 851 | else | ||
| 852 | WARN_ON(1); | ||
| 853 | return buf; | 851 | return buf; |
| 854 | 852 | ||
| 855 | } | 853 | } |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e4966444811..3e2c7c738f2 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -312,7 +312,7 @@ btrfs_lookup_first_block_group(struct btrfs_fs_info *info, u64 bytenr) | |||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | /* | 314 | /* |
| 315 | * return the block group that contains teh given bytenr | 315 | * return the block group that contains the given bytenr |
| 316 | */ | 316 | */ |
| 317 | struct btrfs_block_group_cache *btrfs_lookup_block_group( | 317 | struct btrfs_block_group_cache *btrfs_lookup_block_group( |
| 318 | struct btrfs_fs_info *info, | 318 | struct btrfs_fs_info *info, |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 90c23eb2882..1c8b0190d03 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -3122,6 +3122,7 @@ static noinline void init_btrfs_i(struct inode *inode) | |||
| 3122 | bi->flags = 0; | 3122 | bi->flags = 0; |
| 3123 | bi->index_cnt = (u64)-1; | 3123 | bi->index_cnt = (u64)-1; |
| 3124 | bi->last_unlink_trans = 0; | 3124 | bi->last_unlink_trans = 0; |
| 3125 | bi->ordered_data_close = 0; | ||
| 3125 | extent_map_tree_init(&BTRFS_I(inode)->extent_tree, GFP_NOFS); | 3126 | extent_map_tree_init(&BTRFS_I(inode)->extent_tree, GFP_NOFS); |
| 3126 | extent_io_tree_init(&BTRFS_I(inode)->io_tree, | 3127 | extent_io_tree_init(&BTRFS_I(inode)->io_tree, |
| 3127 | inode->i_mapping, GFP_NOFS); | 3128 | inode->i_mapping, GFP_NOFS); |
| @@ -4295,7 +4296,6 @@ out: | |||
| 4295 | } | 4296 | } |
| 4296 | if (err) { | 4297 | if (err) { |
| 4297 | free_extent_map(em); | 4298 | free_extent_map(em); |
| 4298 | WARN_ON(1); | ||
| 4299 | return ERR_PTR(err); | 4299 | return ERR_PTR(err); |
| 4300 | } | 4300 | } |
| 4301 | return em; | 4301 | return em; |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 5e94ea6e1cb..2624b53ea78 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
| @@ -437,10 +437,6 @@ out_unlock: | |||
| 437 | return 0; | 437 | return 0; |
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | /* | ||
| 441 | * Called inside transaction, so use GFP_NOFS | ||
| 442 | */ | ||
| 443 | |||
| 444 | static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg) | 440 | static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg) |
| 445 | { | 441 | { |
| 446 | u64 new_size; | 442 | u64 new_size; |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 3536bdb2d7c..2ff7cd2db25 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -436,9 +436,9 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 436 | if (btrfs_test_opt(root, SSD)) | 436 | if (btrfs_test_opt(root, SSD)) |
| 437 | seq_puts(seq, ",ssd"); | 437 | seq_puts(seq, ",ssd"); |
| 438 | if (btrfs_test_opt(root, NOTREELOG)) | 438 | if (btrfs_test_opt(root, NOTREELOG)) |
| 439 | seq_puts(seq, ",no-treelog"); | 439 | seq_puts(seq, ",notreelog"); |
| 440 | if (btrfs_test_opt(root, FLUSHONCOMMIT)) | 440 | if (btrfs_test_opt(root, FLUSHONCOMMIT)) |
| 441 | seq_puts(seq, ",flush-on-commit"); | 441 | seq_puts(seq, ",flushoncommit"); |
| 442 | if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) | 442 | if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) |
| 443 | seq_puts(seq, ",noacl"); | 443 | seq_puts(seq, ",noacl"); |
| 444 | return 0; | 444 | return 0; |
| @@ -502,8 +502,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 502 | 502 | ||
| 503 | if (s->s_root) { | 503 | if (s->s_root) { |
| 504 | if ((flags ^ s->s_flags) & MS_RDONLY) { | 504 | if ((flags ^ s->s_flags) & MS_RDONLY) { |
| 505 | up_write(&s->s_umount); | 505 | deactivate_locked_super(s); |
| 506 | deactivate_super(s); | ||
| 507 | error = -EBUSY; | 506 | error = -EBUSY; |
| 508 | goto error_close_devices; | 507 | goto error_close_devices; |
| 509 | } | 508 | } |
| @@ -517,8 +516,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 517 | error = btrfs_fill_super(s, fs_devices, data, | 516 | error = btrfs_fill_super(s, fs_devices, data, |
| 518 | flags & MS_SILENT ? 1 : 0); | 517 | flags & MS_SILENT ? 1 : 0); |
| 519 | if (error) { | 518 | if (error) { |
| 520 | up_write(&s->s_umount); | 519 | deactivate_locked_super(s); |
| 521 | deactivate_super(s); | ||
| 522 | goto error_free_subvol_name; | 520 | goto error_free_subvol_name; |
| 523 | } | 521 | } |
| 524 | 522 | ||
| @@ -535,15 +533,13 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 535 | mutex_unlock(&s->s_root->d_inode->i_mutex); | 533 | mutex_unlock(&s->s_root->d_inode->i_mutex); |
| 536 | 534 | ||
| 537 | if (IS_ERR(root)) { | 535 | if (IS_ERR(root)) { |
| 538 | up_write(&s->s_umount); | 536 | deactivate_locked_super(s); |
| 539 | deactivate_super(s); | ||
| 540 | error = PTR_ERR(root); | 537 | error = PTR_ERR(root); |
| 541 | goto error_free_subvol_name; | 538 | goto error_free_subvol_name; |
| 542 | } | 539 | } |
| 543 | if (!root->d_inode) { | 540 | if (!root->d_inode) { |
| 544 | dput(root); | 541 | dput(root); |
| 545 | up_write(&s->s_umount); | 542 | deactivate_locked_super(s); |
| 546 | deactivate_super(s); | ||
| 547 | error = -ENXIO; | 543 | error = -ENXIO; |
| 548 | goto error_free_subvol_name; | 544 | goto error_free_subvol_name; |
| 549 | } | 545 | } |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 0d6d8b57365..5e6d35804d7 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
| 36 | #include <linux/kthread.h> | 36 | #include <linux/kthread.h> |
| 37 | #include <linux/freezer.h> | 37 | #include <linux/freezer.h> |
| 38 | #include <linux/smp_lock.h> | ||
| 38 | #include "cifsfs.h" | 39 | #include "cifsfs.h" |
| 39 | #include "cifspdu.h" | 40 | #include "cifspdu.h" |
| 40 | #define DECLARE_GLOBALS_HERE | 41 | #define DECLARE_GLOBALS_HERE |
| @@ -530,6 +531,7 @@ static void cifs_umount_begin(struct super_block *sb) | |||
| 530 | if (tcon == NULL) | 531 | if (tcon == NULL) |
| 531 | return; | 532 | return; |
| 532 | 533 | ||
| 534 | lock_kernel(); | ||
| 533 | read_lock(&cifs_tcp_ses_lock); | 535 | read_lock(&cifs_tcp_ses_lock); |
| 534 | if (tcon->tc_count == 1) | 536 | if (tcon->tc_count == 1) |
| 535 | tcon->tidStatus = CifsExiting; | 537 | tcon->tidStatus = CifsExiting; |
| @@ -548,6 +550,7 @@ static void cifs_umount_begin(struct super_block *sb) | |||
| 548 | } | 550 | } |
| 549 | /* BB FIXME - finish add checks for tidStatus BB */ | 551 | /* BB FIXME - finish add checks for tidStatus BB */ |
| 550 | 552 | ||
| 553 | unlock_kernel(); | ||
| 551 | return; | 554 | return; |
| 552 | } | 555 | } |
| 553 | 556 | ||
| @@ -599,8 +602,7 @@ cifs_get_sb(struct file_system_type *fs_type, | |||
| 599 | 602 | ||
| 600 | rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0); | 603 | rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0); |
| 601 | if (rc) { | 604 | if (rc) { |
| 602 | up_write(&sb->s_umount); | 605 | deactivate_locked_super(sb); |
| 603 | deactivate_super(sb); | ||
| 604 | return rc; | 606 | return rc; |
| 605 | } | 607 | } |
| 606 | sb->s_flags |= MS_ACTIVE; | 608 | sb->s_flags |= MS_ACTIVE; |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 75e6623a863..5759ba53dc9 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
| @@ -3976,9 +3976,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
| 3976 | max_len = data_end - temp; | 3976 | max_len = data_end - temp; |
| 3977 | node->path_name = cifs_strndup_from_ucs(temp, max_len, | 3977 | node->path_name = cifs_strndup_from_ucs(temp, max_len, |
| 3978 | is_unicode, nls_codepage); | 3978 | is_unicode, nls_codepage); |
| 3979 | if (IS_ERR(node->path_name)) { | 3979 | if (!node->path_name) { |
| 3980 | rc = PTR_ERR(node->path_name); | 3980 | rc = -ENOMEM; |
| 3981 | node->path_name = NULL; | ||
| 3982 | goto parse_DFS_referrals_exit; | 3981 | goto parse_DFS_referrals_exit; |
| 3983 | } | 3982 | } |
| 3984 | 3983 | ||
| @@ -3987,11 +3986,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
| 3987 | max_len = data_end - temp; | 3986 | max_len = data_end - temp; |
| 3988 | node->node_name = cifs_strndup_from_ucs(temp, max_len, | 3987 | node->node_name = cifs_strndup_from_ucs(temp, max_len, |
| 3989 | is_unicode, nls_codepage); | 3988 | is_unicode, nls_codepage); |
| 3990 | if (IS_ERR(node->node_name)) { | 3989 | if (!node->node_name) |
| 3991 | rc = PTR_ERR(node->node_name); | 3990 | rc = -ENOMEM; |
| 3992 | node->node_name = NULL; | ||
| 3993 | goto parse_DFS_referrals_exit; | ||
| 3994 | } | ||
| 3995 | } | 3991 | } |
| 3996 | 3992 | ||
| 3997 | parse_DFS_referrals_exit: | 3993 | parse_DFS_referrals_exit: |
diff --git a/fs/dcache.c b/fs/dcache.c index 1fcffebfb44..75659a6fd1f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
| @@ -481,7 +481,7 @@ restart: | |||
| 481 | if ((flags & DCACHE_REFERENCED) | 481 | if ((flags & DCACHE_REFERENCED) |
| 482 | && (dentry->d_flags & DCACHE_REFERENCED)) { | 482 | && (dentry->d_flags & DCACHE_REFERENCED)) { |
| 483 | dentry->d_flags &= ~DCACHE_REFERENCED; | 483 | dentry->d_flags &= ~DCACHE_REFERENCED; |
| 484 | list_move_tail(&dentry->d_lru, &referenced); | 484 | list_move(&dentry->d_lru, &referenced); |
| 485 | spin_unlock(&dentry->d_lock); | 485 | spin_unlock(&dentry->d_lock); |
| 486 | } else { | 486 | } else { |
| 487 | list_move_tail(&dentry->d_lru, &tmp); | 487 | list_move_tail(&dentry->d_lru, &tmp); |
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 63a4a59e414..c68edb96944 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
| @@ -90,6 +90,15 @@ static inline struct super_block *pts_sb_from_inode(struct inode *inode) | |||
| 90 | #define PARSE_MOUNT 0 | 90 | #define PARSE_MOUNT 0 |
| 91 | #define PARSE_REMOUNT 1 | 91 | #define PARSE_REMOUNT 1 |
| 92 | 92 | ||
| 93 | /* | ||
| 94 | * parse_mount_options(): | ||
| 95 | * Set @opts to mount options specified in @data. If an option is not | ||
| 96 | * specified in @data, set it to its default value. The exception is | ||
| 97 | * 'newinstance' option which can only be set/cleared on a mount (i.e. | ||
| 98 | * cannot be changed during remount). | ||
| 99 | * | ||
| 100 | * Note: @data may be NULL (in which case all options are set to default). | ||
| 101 | */ | ||
| 93 | static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) | 102 | static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) |
| 94 | { | 103 | { |
| 95 | char *p; | 104 | char *p; |
| @@ -355,12 +364,9 @@ static int devpts_get_sb(struct file_system_type *fs_type, | |||
| 355 | struct pts_mount_opts opts; | 364 | struct pts_mount_opts opts; |
| 356 | struct super_block *s; | 365 | struct super_block *s; |
| 357 | 366 | ||
| 358 | memset(&opts, 0, sizeof(opts)); | 367 | error = parse_mount_options(data, PARSE_MOUNT, &opts); |
| 359 | if (data) { | 368 | if (error) |
| 360 | error = parse_mount_options(data, PARSE_MOUNT, &opts); | 369 | return error; |
| 361 | if (error) | ||
| 362 | return error; | ||
| 363 | } | ||
| 364 | 370 | ||
| 365 | if (opts.newinstance) | 371 | if (opts.newinstance) |
| 366 | s = sget(fs_type, NULL, set_anon_super, NULL); | 372 | s = sget(fs_type, NULL, set_anon_super, NULL); |
| @@ -389,11 +395,10 @@ static int devpts_get_sb(struct file_system_type *fs_type, | |||
| 389 | return 0; | 395 | return 0; |
| 390 | 396 | ||
| 391 | out_dput: | 397 | out_dput: |
| 392 | dput(s->s_root); | 398 | dput(s->s_root); /* undo dget() in simple_set_mnt() */ |
| 393 | 399 | ||
| 394 | out_undo_sget: | 400 | out_undo_sget: |
| 395 | up_write(&s->s_umount); | 401 | deactivate_locked_super(s); |
| 396 | deactivate_super(s); | ||
| 397 | return error; | 402 | return error; |
| 398 | } | 403 | } |
| 399 | 404 | ||
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index ccabd5faa04..9f0aa9883c2 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
| @@ -614,9 +614,8 @@ static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 614 | } | 614 | } |
| 615 | goto out; | 615 | goto out; |
| 616 | out_abort: | 616 | out_abort: |
| 617 | dput(sb->s_root); | 617 | dput(sb->s_root); /* aka mnt->mnt_root, as set by get_sb_nodev() */ |
| 618 | up_write(&sb->s_umount); | 618 | deactivate_locked_super(sb); |
| 619 | deactivate_super(sb); | ||
| 620 | out: | 619 | out: |
| 621 | return rc; | 620 | return rc; |
| 622 | } | 621 | } |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index a89f370fadb..5458e80fc55 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
| @@ -1212,7 +1212,7 @@ SYSCALL_DEFINE1(epoll_create1, int, flags) | |||
| 1212 | 1212 | ||
| 1213 | SYSCALL_DEFINE1(epoll_create, int, size) | 1213 | SYSCALL_DEFINE1(epoll_create, int, size) |
| 1214 | { | 1214 | { |
| 1215 | if (size < 0) | 1215 | if (size <= 0) |
| 1216 | return -EINVAL; | 1216 | return -EINVAL; |
| 1217 | 1217 | ||
| 1218 | return sys_epoll_create1(0); | 1218 | return sys_epoll_create1(0); |
| @@ -105,40 +105,28 @@ static inline void put_binfmt(struct linux_binfmt * fmt) | |||
| 105 | SYSCALL_DEFINE1(uselib, const char __user *, library) | 105 | SYSCALL_DEFINE1(uselib, const char __user *, library) |
| 106 | { | 106 | { |
| 107 | struct file *file; | 107 | struct file *file; |
| 108 | struct nameidata nd; | ||
| 109 | char *tmp = getname(library); | 108 | char *tmp = getname(library); |
| 110 | int error = PTR_ERR(tmp); | 109 | int error = PTR_ERR(tmp); |
| 111 | 110 | ||
| 112 | if (!IS_ERR(tmp)) { | 111 | if (IS_ERR(tmp)) |
| 113 | error = path_lookup_open(AT_FDCWD, tmp, | 112 | goto out; |
| 114 | LOOKUP_FOLLOW, &nd, | 113 | |
| 115 | FMODE_READ|FMODE_EXEC); | 114 | file = do_filp_open(AT_FDCWD, tmp, |
| 116 | putname(tmp); | 115 | O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0, |
| 117 | } | 116 | MAY_READ | MAY_EXEC | MAY_OPEN); |
| 118 | if (error) | 117 | putname(tmp); |
| 118 | error = PTR_ERR(file); | ||
| 119 | if (IS_ERR(file)) | ||
| 119 | goto out; | 120 | goto out; |
| 120 | 121 | ||
| 121 | error = -EINVAL; | 122 | error = -EINVAL; |
| 122 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) | 123 | if (!S_ISREG(file->f_path.dentry->d_inode->i_mode)) |
| 123 | goto exit; | 124 | goto exit; |
| 124 | 125 | ||
| 125 | error = -EACCES; | 126 | error = -EACCES; |
| 126 | if (nd.path.mnt->mnt_flags & MNT_NOEXEC) | 127 | if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) |
| 127 | goto exit; | ||
| 128 | |||
| 129 | error = inode_permission(nd.path.dentry->d_inode, | ||
| 130 | MAY_READ | MAY_EXEC | MAY_OPEN); | ||
| 131 | if (error) | ||
| 132 | goto exit; | ||
| 133 | error = ima_path_check(&nd.path, MAY_READ | MAY_EXEC | MAY_OPEN); | ||
| 134 | if (error) | ||
| 135 | goto exit; | 128 | goto exit; |
| 136 | 129 | ||
| 137 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); | ||
| 138 | error = PTR_ERR(file); | ||
| 139 | if (IS_ERR(file)) | ||
| 140 | goto out; | ||
| 141 | |||
| 142 | fsnotify_open(file->f_path.dentry); | 130 | fsnotify_open(file->f_path.dentry); |
| 143 | 131 | ||
| 144 | error = -ENOEXEC; | 132 | error = -ENOEXEC; |
| @@ -160,13 +148,10 @@ SYSCALL_DEFINE1(uselib, const char __user *, library) | |||
| 160 | } | 148 | } |
| 161 | read_unlock(&binfmt_lock); | 149 | read_unlock(&binfmt_lock); |
| 162 | } | 150 | } |
| 151 | exit: | ||
| 163 | fput(file); | 152 | fput(file); |
| 164 | out: | 153 | out: |
| 165 | return error; | 154 | return error; |
| 166 | exit: | ||
| 167 | release_open_intent(&nd); | ||
| 168 | path_put(&nd.path); | ||
| 169 | goto out; | ||
| 170 | } | 155 | } |
| 171 | 156 | ||
| 172 | #ifdef CONFIG_MMU | 157 | #ifdef CONFIG_MMU |
| @@ -661,47 +646,33 @@ EXPORT_SYMBOL(setup_arg_pages); | |||
| 661 | 646 | ||
| 662 | struct file *open_exec(const char *name) | 647 | struct file *open_exec(const char *name) |
| 663 | { | 648 | { |
| 664 | struct nameidata nd; | ||
| 665 | struct file *file; | 649 | struct file *file; |
| 666 | int err; | 650 | int err; |
| 667 | 651 | ||
| 668 | err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, | 652 | file = do_filp_open(AT_FDCWD, name, |
| 669 | FMODE_READ|FMODE_EXEC); | 653 | O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0, |
| 670 | if (err) | 654 | MAY_EXEC | MAY_OPEN); |
| 655 | if (IS_ERR(file)) | ||
| 671 | goto out; | 656 | goto out; |
| 672 | 657 | ||
| 673 | err = -EACCES; | 658 | err = -EACCES; |
| 674 | if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) | 659 | if (!S_ISREG(file->f_path.dentry->d_inode->i_mode)) |
| 675 | goto out_path_put; | 660 | goto exit; |
| 676 | |||
| 677 | if (nd.path.mnt->mnt_flags & MNT_NOEXEC) | ||
| 678 | goto out_path_put; | ||
| 679 | |||
| 680 | err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN); | ||
| 681 | if (err) | ||
| 682 | goto out_path_put; | ||
| 683 | err = ima_path_check(&nd.path, MAY_EXEC | MAY_OPEN); | ||
| 684 | if (err) | ||
| 685 | goto out_path_put; | ||
| 686 | 661 | ||
| 687 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); | 662 | if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) |
| 688 | if (IS_ERR(file)) | 663 | goto exit; |
| 689 | return file; | ||
| 690 | 664 | ||
| 691 | fsnotify_open(file->f_path.dentry); | 665 | fsnotify_open(file->f_path.dentry); |
| 692 | 666 | ||
| 693 | err = deny_write_access(file); | 667 | err = deny_write_access(file); |
| 694 | if (err) { | 668 | if (err) |
| 695 | fput(file); | 669 | goto exit; |
| 696 | goto out; | ||
| 697 | } | ||
| 698 | 670 | ||
| 671 | out: | ||
| 699 | return file; | 672 | return file; |
| 700 | 673 | ||
| 701 | out_path_put: | 674 | exit: |
| 702 | release_open_intent(&nd); | 675 | fput(file); |
| 703 | path_put(&nd.path); | ||
| 704 | out: | ||
| 705 | return ERR_PTR(err); | 676 | return ERR_PTR(err); |
| 706 | } | 677 | } |
| 707 | EXPORT_SYMBOL(open_exec); | 678 | EXPORT_SYMBOL(open_exec); |
diff --git a/fs/fcntl.c b/fs/fcntl.c index cc8e4de2fee..1ad703150de 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
| @@ -117,11 +117,13 @@ SYSCALL_DEFINE2(dup2, unsigned int, oldfd, unsigned int, newfd) | |||
| 117 | { | 117 | { |
| 118 | if (unlikely(newfd == oldfd)) { /* corner case */ | 118 | if (unlikely(newfd == oldfd)) { /* corner case */ |
| 119 | struct files_struct *files = current->files; | 119 | struct files_struct *files = current->files; |
| 120 | int retval = oldfd; | ||
| 121 | |||
| 120 | rcu_read_lock(); | 122 | rcu_read_lock(); |
| 121 | if (!fcheck_files(files, oldfd)) | 123 | if (!fcheck_files(files, oldfd)) |
| 122 | oldfd = -EBADF; | 124 | retval = -EBADF; |
| 123 | rcu_read_unlock(); | 125 | rcu_read_unlock(); |
| 124 | return oldfd; | 126 | return retval; |
| 125 | } | 127 | } |
| 126 | return sys_dup3(oldfd, newfd, 0); | 128 | return sys_dup3(oldfd, newfd, 0); |
| 127 | } | 129 | } |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 459b73dd45e..91f7c85f1ff 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/random.h> | 19 | #include <linux/random.h> |
| 20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
| 21 | #include <linux/exportfs.h> | 21 | #include <linux/exportfs.h> |
| 22 | #include <linux/smp_lock.h> | ||
| 22 | 23 | ||
| 23 | MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>"); | 24 | MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>"); |
| 24 | MODULE_DESCRIPTION("Filesystem in Userspace"); | 25 | MODULE_DESCRIPTION("Filesystem in Userspace"); |
| @@ -259,7 +260,9 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid, | |||
| 259 | 260 | ||
| 260 | static void fuse_umount_begin(struct super_block *sb) | 261 | static void fuse_umount_begin(struct super_block *sb) |
| 261 | { | 262 | { |
| 263 | lock_kernel(); | ||
| 262 | fuse_abort_conn(get_fuse_conn_super(sb)); | 264 | fuse_abort_conn(get_fuse_conn_super(sb)); |
| 265 | unlock_kernel(); | ||
| 263 | } | 266 | } |
| 264 | 267 | ||
| 265 | static void fuse_send_destroy(struct fuse_conn *fc) | 268 | static void fuse_send_destroy(struct fuse_conn *fc) |
| @@ -908,6 +911,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
| 908 | err_put_root: | 911 | err_put_root: |
| 909 | dput(root_dentry); | 912 | dput(root_dentry); |
| 910 | err_put_conn: | 913 | err_put_conn: |
| 914 | bdi_destroy(&fc->bdi); | ||
| 911 | fuse_conn_put(fc); | 915 | fuse_conn_put(fc); |
| 912 | err_fput: | 916 | err_fput: |
| 913 | fput(file); | 917 | fput(file); |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1afd9f26bcb..ff498109048 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
| @@ -1304,6 +1304,7 @@ static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask) | |||
| 1304 | nr--; | 1304 | nr--; |
| 1305 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | 1305 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) |
| 1306 | gfs2_glock_put(gl); | 1306 | gfs2_glock_put(gl); |
| 1307 | got_ref = 0; | ||
| 1307 | } | 1308 | } |
| 1308 | spin_lock(&lru_lock); | 1309 | spin_lock(&lru_lock); |
| 1309 | if (may_demote) | 1310 | if (may_demote) |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 650a730707b..1ff9473ea75 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
| @@ -1282,21 +1282,21 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags, | |||
| 1282 | static struct super_block *get_gfs2_sb(const char *dev_name) | 1282 | static struct super_block *get_gfs2_sb(const char *dev_name) |
| 1283 | { | 1283 | { |
| 1284 | struct super_block *sb; | 1284 | struct super_block *sb; |
| 1285 | struct nameidata nd; | 1285 | struct path path; |
| 1286 | int error; | 1286 | int error; |
| 1287 | 1287 | ||
| 1288 | error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 1288 | error = kern_path(dev_name, LOOKUP_FOLLOW, &path); |
| 1289 | if (error) { | 1289 | if (error) { |
| 1290 | printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n", | 1290 | printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n", |
| 1291 | dev_name, error); | 1291 | dev_name, error); |
| 1292 | return NULL; | 1292 | return NULL; |
| 1293 | } | 1293 | } |
| 1294 | sb = nd.path.dentry->d_inode->i_sb; | 1294 | sb = path.dentry->d_inode->i_sb; |
| 1295 | if (sb && (sb->s_type == &gfs2_fs_type)) | 1295 | if (sb && (sb->s_type == &gfs2_fs_type)) |
| 1296 | atomic_inc(&sb->s_active); | 1296 | atomic_inc(&sb->s_active); |
| 1297 | else | 1297 | else |
| 1298 | sb = NULL; | 1298 | sb = NULL; |
| 1299 | path_put(&nd.path); | 1299 | path_put(&path); |
| 1300 | return sb; | 1300 | return sb; |
| 1301 | } | 1301 | } |
| 1302 | 1302 | ||
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index fecf402d7b8..fc77965be84 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
| @@ -423,8 +423,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) | |||
| 423 | 423 | ||
| 424 | if (!(*flags & MS_RDONLY)) mark_dirty(s); | 424 | if (!(*flags & MS_RDONLY)) mark_dirty(s); |
| 425 | 425 | ||
| 426 | kfree(s->s_options); | 426 | replace_mount_options(s, new_opts); |
| 427 | s->s_options = new_opts; | ||
| 428 | 427 | ||
| 429 | return 0; | 428 | return 0; |
| 430 | 429 | ||
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 153d9681192..c1462d43e72 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
| @@ -312,16 +312,6 @@ out: | |||
| 312 | return retval; | 312 | return retval; |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | /* | ||
| 316 | * Read a page. Again trivial. If it didn't already exist | ||
| 317 | * in the page cache, it is zero-filled. | ||
| 318 | */ | ||
| 319 | static int hugetlbfs_readpage(struct file *file, struct page * page) | ||
| 320 | { | ||
| 321 | unlock_page(page); | ||
| 322 | return -EINVAL; | ||
| 323 | } | ||
| 324 | |||
| 325 | static int hugetlbfs_write_begin(struct file *file, | 315 | static int hugetlbfs_write_begin(struct file *file, |
| 326 | struct address_space *mapping, | 316 | struct address_space *mapping, |
| 327 | loff_t pos, unsigned len, unsigned flags, | 317 | loff_t pos, unsigned len, unsigned flags, |
| @@ -701,7 +691,6 @@ static void hugetlbfs_destroy_inode(struct inode *inode) | |||
| 701 | } | 691 | } |
| 702 | 692 | ||
| 703 | static const struct address_space_operations hugetlbfs_aops = { | 693 | static const struct address_space_operations hugetlbfs_aops = { |
| 704 | .readpage = hugetlbfs_readpage, | ||
| 705 | .write_begin = hugetlbfs_write_begin, | 694 | .write_begin = hugetlbfs_write_begin, |
| 706 | .write_end = hugetlbfs_write_end, | 695 | .write_end = hugetlbfs_write_end, |
| 707 | .set_page_dirty = hugetlbfs_set_page_dirty, | 696 | .set_page_dirty = hugetlbfs_set_page_dirty, |
diff --git a/fs/inode.c b/fs/inode.c index 6ad14a1cd8c..0571983755d 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
| @@ -99,7 +99,7 @@ static DEFINE_MUTEX(iprune_mutex); | |||
| 99 | */ | 99 | */ |
| 100 | struct inodes_stat_t inodes_stat; | 100 | struct inodes_stat_t inodes_stat; |
| 101 | 101 | ||
| 102 | static struct kmem_cache * inode_cachep __read_mostly; | 102 | static struct kmem_cache *inode_cachep __read_mostly; |
| 103 | 103 | ||
| 104 | static void wake_up_inode(struct inode *inode) | 104 | static void wake_up_inode(struct inode *inode) |
| 105 | { | 105 | { |
| @@ -124,7 +124,7 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode) | |||
| 124 | static struct inode_operations empty_iops; | 124 | static struct inode_operations empty_iops; |
| 125 | static const struct file_operations empty_fops; | 125 | static const struct file_operations empty_fops; |
| 126 | 126 | ||
| 127 | struct address_space * const mapping = &inode->i_data; | 127 | struct address_space *const mapping = &inode->i_data; |
| 128 | 128 | ||
| 129 | inode->i_sb = sb; | 129 | inode->i_sb = sb; |
| 130 | inode->i_blkbits = sb->s_blocksize_bits; | 130 | inode->i_blkbits = sb->s_blocksize_bits; |
| @@ -216,7 +216,7 @@ static struct inode *alloc_inode(struct super_block *sb) | |||
| 216 | return NULL; | 216 | return NULL; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | void destroy_inode(struct inode *inode) | 219 | void destroy_inode(struct inode *inode) |
| 220 | { | 220 | { |
| 221 | BUG_ON(inode_has_buffers(inode)); | 221 | BUG_ON(inode_has_buffers(inode)); |
| 222 | security_inode_free(inode); | 222 | security_inode_free(inode); |
| @@ -252,12 +252,11 @@ void inode_init_once(struct inode *inode) | |||
| 252 | mutex_init(&inode->inotify_mutex); | 252 | mutex_init(&inode->inotify_mutex); |
| 253 | #endif | 253 | #endif |
| 254 | } | 254 | } |
| 255 | |||
| 256 | EXPORT_SYMBOL(inode_init_once); | 255 | EXPORT_SYMBOL(inode_init_once); |
| 257 | 256 | ||
| 258 | static void init_once(void *foo) | 257 | static void init_once(void *foo) |
| 259 | { | 258 | { |
| 260 | struct inode * inode = (struct inode *) foo; | 259 | struct inode *inode = (struct inode *) foo; |
| 261 | 260 | ||
| 262 | inode_init_once(inode); | 261 | inode_init_once(inode); |
| 263 | } | 262 | } |
| @@ -265,7 +264,7 @@ static void init_once(void *foo) | |||
| 265 | /* | 264 | /* |
| 266 | * inode_lock must be held | 265 | * inode_lock must be held |
| 267 | */ | 266 | */ |
| 268 | void __iget(struct inode * inode) | 267 | void __iget(struct inode *inode) |
| 269 | { | 268 | { |
| 270 | if (atomic_read(&inode->i_count)) { | 269 | if (atomic_read(&inode->i_count)) { |
| 271 | atomic_inc(&inode->i_count); | 270 | atomic_inc(&inode->i_count); |
| @@ -289,7 +288,7 @@ void clear_inode(struct inode *inode) | |||
| 289 | { | 288 | { |
| 290 | might_sleep(); | 289 | might_sleep(); |
| 291 | invalidate_inode_buffers(inode); | 290 | invalidate_inode_buffers(inode); |
| 292 | 291 | ||
| 293 | BUG_ON(inode->i_data.nrpages); | 292 | BUG_ON(inode->i_data.nrpages); |
| 294 | BUG_ON(!(inode->i_state & I_FREEING)); | 293 | BUG_ON(!(inode->i_state & I_FREEING)); |
| 295 | BUG_ON(inode->i_state & I_CLEAR); | 294 | BUG_ON(inode->i_state & I_CLEAR); |
| @@ -303,7 +302,6 @@ void clear_inode(struct inode *inode) | |||
| 303 | cd_forget(inode); | 302 | cd_forget(inode); |
| 304 | inode->i_state = I_CLEAR; | 303 | inode->i_state = I_CLEAR; |
| 305 | } | 304 | } |
| 306 | |||
| 307 | EXPORT_SYMBOL(clear_inode); | 305 | EXPORT_SYMBOL(clear_inode); |
| 308 | 306 | ||
| 309 | /* | 307 | /* |
| @@ -351,8 +349,8 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose) | |||
| 351 | 349 | ||
| 352 | next = head->next; | 350 | next = head->next; |
| 353 | for (;;) { | 351 | for (;;) { |
| 354 | struct list_head * tmp = next; | 352 | struct list_head *tmp = next; |
| 355 | struct inode * inode; | 353 | struct inode *inode; |
| 356 | 354 | ||
| 357 | /* | 355 | /* |
| 358 | * We can reschedule here without worrying about the list's | 356 | * We can reschedule here without worrying about the list's |
| @@ -391,7 +389,7 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose) | |||
| 391 | * fails because there are busy inodes then a non zero value is returned. | 389 | * fails because there are busy inodes then a non zero value is returned. |
| 392 | * If the discard is successful all the inodes have been discarded. | 390 | * If the discard is successful all the inodes have been discarded. |
| 393 | */ | 391 | */ |
| 394 | int invalidate_inodes(struct super_block * sb) | 392 | int invalidate_inodes(struct super_block *sb) |
| 395 | { | 393 | { |
| 396 | int busy; | 394 | int busy; |
| 397 | LIST_HEAD(throw_away); | 395 | LIST_HEAD(throw_away); |
| @@ -407,7 +405,6 @@ int invalidate_inodes(struct super_block * sb) | |||
| 407 | 405 | ||
| 408 | return busy; | 406 | return busy; |
| 409 | } | 407 | } |
| 410 | |||
| 411 | EXPORT_SYMBOL(invalidate_inodes); | 408 | EXPORT_SYMBOL(invalidate_inodes); |
| 412 | 409 | ||
| 413 | static int can_unuse(struct inode *inode) | 410 | static int can_unuse(struct inode *inode) |
| @@ -504,7 +501,7 @@ static int shrink_icache_memory(int nr, gfp_t gfp_mask) | |||
| 504 | * Nasty deadlock avoidance. We may hold various FS locks, | 501 | * Nasty deadlock avoidance. We may hold various FS locks, |
| 505 | * and we don't want to recurse into the FS that called us | 502 | * and we don't want to recurse into the FS that called us |
| 506 | * in clear_inode() and friends.. | 503 | * in clear_inode() and friends.. |
| 507 | */ | 504 | */ |
| 508 | if (!(gfp_mask & __GFP_FS)) | 505 | if (!(gfp_mask & __GFP_FS)) |
| 509 | return -1; | 506 | return -1; |
| 510 | prune_icache(nr); | 507 | prune_icache(nr); |
| @@ -524,10 +521,13 @@ static void __wait_on_freeing_inode(struct inode *inode); | |||
| 524 | * by hand after calling find_inode now! This simplifies iunique and won't | 521 | * by hand after calling find_inode now! This simplifies iunique and won't |
| 525 | * add any additional branch in the common code. | 522 | * add any additional branch in the common code. |
| 526 | */ | 523 | */ |
| 527 | static struct inode * find_inode(struct super_block * sb, struct hlist_head *head, int (*test)(struct inode *, void *), void *data) | 524 | static struct inode *find_inode(struct super_block *sb, |
| 525 | struct hlist_head *head, | ||
| 526 | int (*test)(struct inode *, void *), | ||
| 527 | void *data) | ||
| 528 | { | 528 | { |
| 529 | struct hlist_node *node; | 529 | struct hlist_node *node; |
| 530 | struct inode * inode = NULL; | 530 | struct inode *inode = NULL; |
| 531 | 531 | ||
| 532 | repeat: | 532 | repeat: |
| 533 | hlist_for_each_entry(inode, node, head, i_hash) { | 533 | hlist_for_each_entry(inode, node, head, i_hash) { |
| @@ -548,10 +548,11 @@ repeat: | |||
| 548 | * find_inode_fast is the fast path version of find_inode, see the comment at | 548 | * find_inode_fast is the fast path version of find_inode, see the comment at |
| 549 | * iget_locked for details. | 549 | * iget_locked for details. |
| 550 | */ | 550 | */ |
| 551 | static struct inode * find_inode_fast(struct super_block * sb, struct hlist_head *head, unsigned long ino) | 551 | static struct inode *find_inode_fast(struct super_block *sb, |
| 552 | struct hlist_head *head, unsigned long ino) | ||
| 552 | { | 553 | { |
| 553 | struct hlist_node *node; | 554 | struct hlist_node *node; |
| 554 | struct inode * inode = NULL; | 555 | struct inode *inode = NULL; |
| 555 | 556 | ||
| 556 | repeat: | 557 | repeat: |
| 557 | hlist_for_each_entry(inode, node, head, i_hash) { | 558 | hlist_for_each_entry(inode, node, head, i_hash) { |
| @@ -631,10 +632,10 @@ struct inode *new_inode(struct super_block *sb) | |||
| 631 | * here to attempt to avoid that. | 632 | * here to attempt to avoid that. |
| 632 | */ | 633 | */ |
| 633 | static unsigned int last_ino; | 634 | static unsigned int last_ino; |
| 634 | struct inode * inode; | 635 | struct inode *inode; |
| 635 | 636 | ||
| 636 | spin_lock_prefetch(&inode_lock); | 637 | spin_lock_prefetch(&inode_lock); |
| 637 | 638 | ||
| 638 | inode = alloc_inode(sb); | 639 | inode = alloc_inode(sb); |
| 639 | if (inode) { | 640 | if (inode) { |
| 640 | spin_lock(&inode_lock); | 641 | spin_lock(&inode_lock); |
| @@ -645,7 +646,6 @@ struct inode *new_inode(struct super_block *sb) | |||
| 645 | } | 646 | } |
| 646 | return inode; | 647 | return inode; |
| 647 | } | 648 | } |
| 648 | |||
| 649 | EXPORT_SYMBOL(new_inode); | 649 | EXPORT_SYMBOL(new_inode); |
| 650 | 650 | ||
| 651 | void unlock_new_inode(struct inode *inode) | 651 | void unlock_new_inode(struct inode *inode) |
| @@ -674,7 +674,6 @@ void unlock_new_inode(struct inode *inode) | |||
| 674 | inode->i_state &= ~(I_LOCK|I_NEW); | 674 | inode->i_state &= ~(I_LOCK|I_NEW); |
| 675 | wake_up_inode(inode); | 675 | wake_up_inode(inode); |
| 676 | } | 676 | } |
| 677 | |||
| 678 | EXPORT_SYMBOL(unlock_new_inode); | 677 | EXPORT_SYMBOL(unlock_new_inode); |
| 679 | 678 | ||
| 680 | /* | 679 | /* |
| @@ -683,13 +682,17 @@ EXPORT_SYMBOL(unlock_new_inode); | |||
| 683 | * We no longer cache the sb_flags in i_flags - see fs.h | 682 | * We no longer cache the sb_flags in i_flags - see fs.h |
| 684 | * -- rmk@arm.uk.linux.org | 683 | * -- rmk@arm.uk.linux.org |
| 685 | */ | 684 | */ |
| 686 | static struct inode * get_new_inode(struct super_block *sb, struct hlist_head *head, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *data) | 685 | static struct inode *get_new_inode(struct super_block *sb, |
| 686 | struct hlist_head *head, | ||
| 687 | int (*test)(struct inode *, void *), | ||
| 688 | int (*set)(struct inode *, void *), | ||
| 689 | void *data) | ||
| 687 | { | 690 | { |
| 688 | struct inode * inode; | 691 | struct inode *inode; |
| 689 | 692 | ||
| 690 | inode = alloc_inode(sb); | 693 | inode = alloc_inode(sb); |
| 691 | if (inode) { | 694 | if (inode) { |
| 692 | struct inode * old; | 695 | struct inode *old; |
| 693 | 696 | ||
| 694 | spin_lock(&inode_lock); | 697 | spin_lock(&inode_lock); |
| 695 | /* We released the lock, so.. */ | 698 | /* We released the lock, so.. */ |
| @@ -731,13 +734,14 @@ set_failed: | |||
| 731 | * get_new_inode_fast is the fast path version of get_new_inode, see the | 734 | * get_new_inode_fast is the fast path version of get_new_inode, see the |
| 732 | * comment at iget_locked for details. | 735 | * comment at iget_locked for details. |
| 733 | */ | 736 | */ |
| 734 | static struct inode * get_new_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned long ino) | 737 | static struct inode *get_new_inode_fast(struct super_block *sb, |
| 738 | struct hlist_head *head, unsigned long ino) | ||
| 735 | { | 739 | { |
| 736 | struct inode * inode; | 740 | struct inode *inode; |
| 737 | 741 | ||
| 738 | inode = alloc_inode(sb); | 742 | inode = alloc_inode(sb); |
| 739 | if (inode) { | 743 | if (inode) { |
| 740 | struct inode * old; | 744 | struct inode *old; |
| 741 | 745 | ||
| 742 | spin_lock(&inode_lock); | 746 | spin_lock(&inode_lock); |
| 743 | /* We released the lock, so.. */ | 747 | /* We released the lock, so.. */ |
| @@ -823,7 +827,6 @@ struct inode *igrab(struct inode *inode) | |||
| 823 | spin_unlock(&inode_lock); | 827 | spin_unlock(&inode_lock); |
| 824 | return inode; | 828 | return inode; |
| 825 | } | 829 | } |
| 826 | |||
| 827 | EXPORT_SYMBOL(igrab); | 830 | EXPORT_SYMBOL(igrab); |
| 828 | 831 | ||
| 829 | /** | 832 | /** |
| @@ -924,7 +927,6 @@ struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, | |||
| 924 | 927 | ||
| 925 | return ifind(sb, head, test, data, 0); | 928 | return ifind(sb, head, test, data, 0); |
| 926 | } | 929 | } |
| 927 | |||
| 928 | EXPORT_SYMBOL(ilookup5_nowait); | 930 | EXPORT_SYMBOL(ilookup5_nowait); |
| 929 | 931 | ||
| 930 | /** | 932 | /** |
| @@ -953,7 +955,6 @@ struct inode *ilookup5(struct super_block *sb, unsigned long hashval, | |||
| 953 | 955 | ||
| 954 | return ifind(sb, head, test, data, 1); | 956 | return ifind(sb, head, test, data, 1); |
| 955 | } | 957 | } |
| 956 | |||
| 957 | EXPORT_SYMBOL(ilookup5); | 958 | EXPORT_SYMBOL(ilookup5); |
| 958 | 959 | ||
| 959 | /** | 960 | /** |
| @@ -976,7 +977,6 @@ struct inode *ilookup(struct super_block *sb, unsigned long ino) | |||
| 976 | 977 | ||
| 977 | return ifind_fast(sb, head, ino); | 978 | return ifind_fast(sb, head, ino); |
| 978 | } | 979 | } |
| 979 | |||
| 980 | EXPORT_SYMBOL(ilookup); | 980 | EXPORT_SYMBOL(ilookup); |
| 981 | 981 | ||
| 982 | /** | 982 | /** |
| @@ -1015,7 +1015,6 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, | |||
| 1015 | */ | 1015 | */ |
| 1016 | return get_new_inode(sb, head, test, set, data); | 1016 | return get_new_inode(sb, head, test, set, data); |
| 1017 | } | 1017 | } |
| 1018 | |||
| 1019 | EXPORT_SYMBOL(iget5_locked); | 1018 | EXPORT_SYMBOL(iget5_locked); |
| 1020 | 1019 | ||
| 1021 | /** | 1020 | /** |
| @@ -1047,7 +1046,6 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino) | |||
| 1047 | */ | 1046 | */ |
| 1048 | return get_new_inode_fast(sb, head, ino); | 1047 | return get_new_inode_fast(sb, head, ino); |
| 1049 | } | 1048 | } |
| 1050 | |||
| 1051 | EXPORT_SYMBOL(iget_locked); | 1049 | EXPORT_SYMBOL(iget_locked); |
| 1052 | 1050 | ||
| 1053 | int insert_inode_locked(struct inode *inode) | 1051 | int insert_inode_locked(struct inode *inode) |
| @@ -1076,7 +1074,6 @@ int insert_inode_locked(struct inode *inode) | |||
| 1076 | iput(old); | 1074 | iput(old); |
| 1077 | } | 1075 | } |
| 1078 | } | 1076 | } |
| 1079 | |||
| 1080 | EXPORT_SYMBOL(insert_inode_locked); | 1077 | EXPORT_SYMBOL(insert_inode_locked); |
| 1081 | 1078 | ||
| 1082 | int insert_inode_locked4(struct inode *inode, unsigned long hashval, | 1079 | int insert_inode_locked4(struct inode *inode, unsigned long hashval, |
| @@ -1106,7 +1103,6 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, | |||
| 1106 | iput(old); | 1103 | iput(old); |
| 1107 | } | 1104 | } |
| 1108 | } | 1105 | } |
| 1109 | |||
| 1110 | EXPORT_SYMBOL(insert_inode_locked4); | 1106 | EXPORT_SYMBOL(insert_inode_locked4); |
| 1111 | 1107 | ||
| 1112 | /** | 1108 | /** |
| @@ -1124,7 +1120,6 @@ void __insert_inode_hash(struct inode *inode, unsigned long hashval) | |||
| 1124 | hlist_add_head(&inode->i_hash, head); | 1120 | hlist_add_head(&inode->i_hash, head); |
| 1125 | spin_unlock(&inode_lock); | 1121 | spin_unlock(&inode_lock); |
| 1126 | } | 1122 | } |
| 1127 | |||
| 1128 | EXPORT_SYMBOL(__insert_inode_hash); | 1123 | EXPORT_SYMBOL(__insert_inode_hash); |
| 1129 | 1124 | ||
| 1130 | /** | 1125 | /** |
| @@ -1139,7 +1134,6 @@ void remove_inode_hash(struct inode *inode) | |||
| 1139 | hlist_del_init(&inode->i_hash); | 1134 | hlist_del_init(&inode->i_hash); |
| 1140 | spin_unlock(&inode_lock); | 1135 | spin_unlock(&inode_lock); |
| 1141 | } | 1136 | } |
| 1142 | |||
| 1143 | EXPORT_SYMBOL(remove_inode_hash); | 1137 | EXPORT_SYMBOL(remove_inode_hash); |
| 1144 | 1138 | ||
| 1145 | /* | 1139 | /* |
| @@ -1187,7 +1181,6 @@ void generic_delete_inode(struct inode *inode) | |||
| 1187 | BUG_ON(inode->i_state != I_CLEAR); | 1181 | BUG_ON(inode->i_state != I_CLEAR); |
| 1188 | destroy_inode(inode); | 1182 | destroy_inode(inode); |
| 1189 | } | 1183 | } |
| 1190 | |||
| 1191 | EXPORT_SYMBOL(generic_delete_inode); | 1184 | EXPORT_SYMBOL(generic_delete_inode); |
| 1192 | 1185 | ||
| 1193 | static void generic_forget_inode(struct inode *inode) | 1186 | static void generic_forget_inode(struct inode *inode) |
| @@ -1237,12 +1230,11 @@ void generic_drop_inode(struct inode *inode) | |||
| 1237 | else | 1230 | else |
| 1238 | generic_forget_inode(inode); | 1231 | generic_forget_inode(inode); |
| 1239 | } | 1232 | } |
| 1240 | |||
| 1241 | EXPORT_SYMBOL_GPL(generic_drop_inode); | 1233 | EXPORT_SYMBOL_GPL(generic_drop_inode); |
| 1242 | 1234 | ||
| 1243 | /* | 1235 | /* |
| 1244 | * Called when we're dropping the last reference | 1236 | * Called when we're dropping the last reference |
| 1245 | * to an inode. | 1237 | * to an inode. |
| 1246 | * | 1238 | * |
| 1247 | * Call the FS "drop()" function, defaulting to | 1239 | * Call the FS "drop()" function, defaulting to |
| 1248 | * the legacy UNIX filesystem behaviour.. | 1240 | * the legacy UNIX filesystem behaviour.. |
| @@ -1262,7 +1254,7 @@ static inline void iput_final(struct inode *inode) | |||
| 1262 | } | 1254 | } |
| 1263 | 1255 | ||
| 1264 | /** | 1256 | /** |
| 1265 | * iput - put an inode | 1257 | * iput - put an inode |
| 1266 | * @inode: inode to put | 1258 | * @inode: inode to put |
| 1267 | * | 1259 | * |
| 1268 | * Puts an inode, dropping its usage count. If the inode use count hits | 1260 | * Puts an inode, dropping its usage count. If the inode use count hits |
| @@ -1279,7 +1271,6 @@ void iput(struct inode *inode) | |||
| 1279 | iput_final(inode); | 1271 | iput_final(inode); |
| 1280 | } | 1272 | } |
| 1281 | } | 1273 | } |
| 1282 | |||
| 1283 | EXPORT_SYMBOL(iput); | 1274 | EXPORT_SYMBOL(iput); |
| 1284 | 1275 | ||
| 1285 | /** | 1276 | /** |
| @@ -1290,10 +1281,10 @@ EXPORT_SYMBOL(iput); | |||
| 1290 | * Returns the block number on the device holding the inode that | 1281 | * Returns the block number on the device holding the inode that |
| 1291 | * is the disk block number for the block of the file requested. | 1282 | * is the disk block number for the block of the file requested. |
| 1292 | * That is, asked for block 4 of inode 1 the function will return the | 1283 | * That is, asked for block 4 of inode 1 the function will return the |
| 1293 | * disk block relative to the disk start that holds that block of the | 1284 | * disk block relative to the disk start that holds that block of the |
| 1294 | * file. | 1285 | * file. |
| 1295 | */ | 1286 | */ |
| 1296 | sector_t bmap(struct inode * inode, sector_t block) | 1287 | sector_t bmap(struct inode *inode, sector_t block) |
| 1297 | { | 1288 | { |
| 1298 | sector_t res = 0; | 1289 | sector_t res = 0; |
| 1299 | if (inode->i_mapping->a_ops->bmap) | 1290 | if (inode->i_mapping->a_ops->bmap) |
| @@ -1425,7 +1416,6 @@ void file_update_time(struct file *file) | |||
| 1425 | mark_inode_dirty_sync(inode); | 1416 | mark_inode_dirty_sync(inode); |
| 1426 | mnt_drop_write(file->f_path.mnt); | 1417 | mnt_drop_write(file->f_path.mnt); |
| 1427 | } | 1418 | } |
| 1428 | |||
| 1429 | EXPORT_SYMBOL(file_update_time); | 1419 | EXPORT_SYMBOL(file_update_time); |
| 1430 | 1420 | ||
| 1431 | int inode_needs_sync(struct inode *inode) | 1421 | int inode_needs_sync(struct inode *inode) |
| @@ -1436,7 +1426,6 @@ int inode_needs_sync(struct inode *inode) | |||
| 1436 | return 1; | 1426 | return 1; |
| 1437 | return 0; | 1427 | return 0; |
| 1438 | } | 1428 | } |
| 1439 | |||
| 1440 | EXPORT_SYMBOL(inode_needs_sync); | 1429 | EXPORT_SYMBOL(inode_needs_sync); |
| 1441 | 1430 | ||
| 1442 | int inode_wait(void *word) | 1431 | int inode_wait(void *word) |
diff --git a/fs/libfs.c b/fs/libfs.c index cd223190c4e..80046ddf506 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
| @@ -246,8 +246,7 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name, | |||
| 246 | return 0; | 246 | return 0; |
| 247 | 247 | ||
| 248 | Enomem: | 248 | Enomem: |
| 249 | up_write(&s->s_umount); | 249 | deactivate_locked_super(s); |
| 250 | deactivate_super(s); | ||
| 251 | return -ENOMEM; | 250 | return -ENOMEM; |
| 252 | } | 251 | } |
| 253 | 252 | ||
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index abf83881f68..1a54ae14a19 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
| @@ -104,6 +104,16 @@ static void set_grace_period(void) | |||
| 104 | schedule_delayed_work(&grace_period_end, grace_period); | 104 | schedule_delayed_work(&grace_period_end, grace_period); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | static void restart_grace(void) | ||
| 108 | { | ||
| 109 | if (nlmsvc_ops) { | ||
| 110 | cancel_delayed_work_sync(&grace_period_end); | ||
| 111 | locks_end_grace(&lockd_manager); | ||
| 112 | nlmsvc_invalidate_all(); | ||
| 113 | set_grace_period(); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 107 | /* | 117 | /* |
| 108 | * This is the lockd kernel thread | 118 | * This is the lockd kernel thread |
| 109 | */ | 119 | */ |
| @@ -149,10 +159,7 @@ lockd(void *vrqstp) | |||
| 149 | 159 | ||
| 150 | if (signalled()) { | 160 | if (signalled()) { |
| 151 | flush_signals(current); | 161 | flush_signals(current); |
| 152 | if (nlmsvc_ops) { | 162 | restart_grace(); |
| 153 | nlmsvc_invalidate_all(); | ||
| 154 | set_grace_period(); | ||
| 155 | } | ||
| 156 | continue; | 163 | continue; |
| 157 | } | 164 | } |
| 158 | 165 | ||
diff --git a/fs/namei.c b/fs/namei.c index 78f253cd2d4..967c3db9272 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -1130,8 +1130,8 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, | |||
| 1130 | * @nd: pointer to nameidata | 1130 | * @nd: pointer to nameidata |
| 1131 | * @open_flags: open intent flags | 1131 | * @open_flags: open intent flags |
| 1132 | */ | 1132 | */ |
| 1133 | int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags, | 1133 | static int path_lookup_open(int dfd, const char *name, |
| 1134 | struct nameidata *nd, int open_flags) | 1134 | unsigned int lookup_flags, struct nameidata *nd, int open_flags) |
| 1135 | { | 1135 | { |
| 1136 | struct file *filp = get_empty_filp(); | 1136 | struct file *filp = get_empty_filp(); |
| 1137 | int err; | 1137 | int err; |
| @@ -1637,18 +1637,19 @@ static int open_will_write_to_fs(int flag, struct inode *inode) | |||
| 1637 | * open_to_namei_flags() for more details. | 1637 | * open_to_namei_flags() for more details. |
| 1638 | */ | 1638 | */ |
| 1639 | struct file *do_filp_open(int dfd, const char *pathname, | 1639 | struct file *do_filp_open(int dfd, const char *pathname, |
| 1640 | int open_flag, int mode) | 1640 | int open_flag, int mode, int acc_mode) |
| 1641 | { | 1641 | { |
| 1642 | struct file *filp; | 1642 | struct file *filp; |
| 1643 | struct nameidata nd; | 1643 | struct nameidata nd; |
| 1644 | int acc_mode, error; | 1644 | int error; |
| 1645 | struct path path; | 1645 | struct path path; |
| 1646 | struct dentry *dir; | 1646 | struct dentry *dir; |
| 1647 | int count = 0; | 1647 | int count = 0; |
| 1648 | int will_write; | 1648 | int will_write; |
| 1649 | int flag = open_to_namei_flags(open_flag); | 1649 | int flag = open_to_namei_flags(open_flag); |
| 1650 | 1650 | ||
| 1651 | acc_mode = MAY_OPEN | ACC_MODE(flag); | 1651 | if (!acc_mode) |
| 1652 | acc_mode = MAY_OPEN | ACC_MODE(flag); | ||
| 1652 | 1653 | ||
| 1653 | /* O_TRUNC implies we need access checks for write permissions */ | 1654 | /* O_TRUNC implies we need access checks for write permissions */ |
| 1654 | if (flag & O_TRUNC) | 1655 | if (flag & O_TRUNC) |
| @@ -1869,7 +1870,7 @@ do_link: | |||
| 1869 | */ | 1870 | */ |
| 1870 | struct file *filp_open(const char *filename, int flags, int mode) | 1871 | struct file *filp_open(const char *filename, int flags, int mode) |
| 1871 | { | 1872 | { |
| 1872 | return do_filp_open(AT_FDCWD, filename, flags, mode); | 1873 | return do_filp_open(AT_FDCWD, filename, flags, mode, 0); |
| 1873 | } | 1874 | } |
| 1874 | EXPORT_SYMBOL(filp_open); | 1875 | EXPORT_SYMBOL(filp_open); |
| 1875 | 1876 | ||
diff --git a/fs/namespace.c b/fs/namespace.c index 41196209a90..134d494158d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
| @@ -695,12 +695,16 @@ static inline void mangle(struct seq_file *m, const char *s) | |||
| 695 | */ | 695 | */ |
| 696 | int generic_show_options(struct seq_file *m, struct vfsmount *mnt) | 696 | int generic_show_options(struct seq_file *m, struct vfsmount *mnt) |
| 697 | { | 697 | { |
| 698 | const char *options = mnt->mnt_sb->s_options; | 698 | const char *options; |
| 699 | |||
| 700 | rcu_read_lock(); | ||
| 701 | options = rcu_dereference(mnt->mnt_sb->s_options); | ||
| 699 | 702 | ||
| 700 | if (options != NULL && options[0]) { | 703 | if (options != NULL && options[0]) { |
| 701 | seq_putc(m, ','); | 704 | seq_putc(m, ','); |
| 702 | mangle(m, options); | 705 | mangle(m, options); |
| 703 | } | 706 | } |
| 707 | rcu_read_unlock(); | ||
| 704 | 708 | ||
| 705 | return 0; | 709 | return 0; |
| 706 | } | 710 | } |
| @@ -721,11 +725,22 @@ EXPORT_SYMBOL(generic_show_options); | |||
| 721 | */ | 725 | */ |
| 722 | void save_mount_options(struct super_block *sb, char *options) | 726 | void save_mount_options(struct super_block *sb, char *options) |
| 723 | { | 727 | { |
| 724 | kfree(sb->s_options); | 728 | BUG_ON(sb->s_options); |
| 725 | sb->s_options = kstrdup(options, GFP_KERNEL); | 729 | rcu_assign_pointer(sb->s_options, kstrdup(options, GFP_KERNEL)); |
| 726 | } | 730 | } |
| 727 | EXPORT_SYMBOL(save_mount_options); | 731 | EXPORT_SYMBOL(save_mount_options); |
| 728 | 732 | ||
| 733 | void replace_mount_options(struct super_block *sb, char *options) | ||
| 734 | { | ||
| 735 | char *old = sb->s_options; | ||
| 736 | rcu_assign_pointer(sb->s_options, options); | ||
| 737 | if (old) { | ||
| 738 | synchronize_rcu(); | ||
| 739 | kfree(old); | ||
| 740 | } | ||
| 741 | } | ||
| 742 | EXPORT_SYMBOL(replace_mount_options); | ||
| 743 | |||
| 729 | #ifdef CONFIG_PROC_FS | 744 | #ifdef CONFIG_PROC_FS |
| 730 | /* iterator */ | 745 | /* iterator */ |
| 731 | static void *m_start(struct seq_file *m, loff_t *pos) | 746 | static void *m_start(struct seq_file *m, loff_t *pos) |
| @@ -1073,9 +1088,7 @@ static int do_umount(struct vfsmount *mnt, int flags) | |||
| 1073 | */ | 1088 | */ |
| 1074 | 1089 | ||
| 1075 | if (flags & MNT_FORCE && sb->s_op->umount_begin) { | 1090 | if (flags & MNT_FORCE && sb->s_op->umount_begin) { |
| 1076 | lock_kernel(); | ||
| 1077 | sb->s_op->umount_begin(sb); | 1091 | sb->s_op->umount_begin(sb); |
| 1078 | unlock_kernel(); | ||
| 1079 | } | 1092 | } |
| 1080 | 1093 | ||
| 1081 | /* | 1094 | /* |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 6717200923f..d2d67781c57 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
| @@ -683,9 +683,12 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) | |||
| 683 | */ | 683 | */ |
| 684 | static void nfs_umount_begin(struct super_block *sb) | 684 | static void nfs_umount_begin(struct super_block *sb) |
| 685 | { | 685 | { |
| 686 | struct nfs_server *server = NFS_SB(sb); | 686 | struct nfs_server *server; |
| 687 | struct rpc_clnt *rpc; | 687 | struct rpc_clnt *rpc; |
| 688 | 688 | ||
| 689 | lock_kernel(); | ||
| 690 | |||
| 691 | server = NFS_SB(sb); | ||
| 689 | /* -EIO all pending I/O */ | 692 | /* -EIO all pending I/O */ |
| 690 | rpc = server->client_acl; | 693 | rpc = server->client_acl; |
| 691 | if (!IS_ERR(rpc)) | 694 | if (!IS_ERR(rpc)) |
| @@ -693,6 +696,8 @@ static void nfs_umount_begin(struct super_block *sb) | |||
| 693 | rpc = server->client; | 696 | rpc = server->client; |
| 694 | if (!IS_ERR(rpc)) | 697 | if (!IS_ERR(rpc)) |
| 695 | rpc_killall_tasks(rpc); | 698 | rpc_killall_tasks(rpc); |
| 699 | |||
| 700 | unlock_kernel(); | ||
| 696 | } | 701 | } |
| 697 | 702 | ||
| 698 | /* | 703 | /* |
| @@ -2106,8 +2111,7 @@ out_err_nosb: | |||
| 2106 | error_splat_root: | 2111 | error_splat_root: |
| 2107 | dput(mntroot); | 2112 | dput(mntroot); |
| 2108 | error_splat_super: | 2113 | error_splat_super: |
| 2109 | up_write(&s->s_umount); | 2114 | deactivate_locked_super(s); |
| 2110 | deactivate_super(s); | ||
| 2111 | goto out; | 2115 | goto out; |
| 2112 | } | 2116 | } |
| 2113 | 2117 | ||
| @@ -2203,8 +2207,7 @@ out_err_noserver: | |||
| 2203 | return error; | 2207 | return error; |
| 2204 | 2208 | ||
| 2205 | error_splat_super: | 2209 | error_splat_super: |
| 2206 | up_write(&s->s_umount); | 2210 | deactivate_locked_super(s); |
| 2207 | deactivate_super(s); | ||
| 2208 | dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); | 2211 | dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); |
| 2209 | return error; | 2212 | return error; |
| 2210 | } | 2213 | } |
| @@ -2464,8 +2467,7 @@ out_free: | |||
| 2464 | error_splat_root: | 2467 | error_splat_root: |
| 2465 | dput(mntroot); | 2468 | dput(mntroot); |
| 2466 | error_splat_super: | 2469 | error_splat_super: |
| 2467 | up_write(&s->s_umount); | 2470 | deactivate_locked_super(s); |
| 2468 | deactivate_super(s); | ||
| 2469 | goto out; | 2471 | goto out; |
| 2470 | } | 2472 | } |
| 2471 | 2473 | ||
| @@ -2559,8 +2561,7 @@ out_err_noserver: | |||
| 2559 | return error; | 2561 | return error; |
| 2560 | 2562 | ||
| 2561 | error_splat_super: | 2563 | error_splat_super: |
| 2562 | up_write(&s->s_umount); | 2564 | deactivate_locked_super(s); |
| 2563 | deactivate_super(s); | ||
| 2564 | dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); | 2565 | dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); |
| 2565 | return error; | 2566 | return error; |
| 2566 | } | 2567 | } |
| @@ -2644,8 +2645,7 @@ out_err_noserver: | |||
| 2644 | return error; | 2645 | return error; |
| 2645 | 2646 | ||
| 2646 | error_splat_super: | 2647 | error_splat_super: |
| 2647 | up_write(&s->s_umount); | 2648 | deactivate_locked_super(s); |
| 2648 | deactivate_super(s); | ||
| 2649 | dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); | 2649 | dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); |
| 2650 | return error; | 2650 | return error; |
| 2651 | } | 2651 | } |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 5275097a756..b5348405046 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
| @@ -229,7 +229,7 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f) | |||
| 229 | goto out; | 229 | goto out; |
| 230 | status = vfs_readdir(filp, nfsd4_build_namelist, &names); | 230 | status = vfs_readdir(filp, nfsd4_build_namelist, &names); |
| 231 | fput(filp); | 231 | fput(filp); |
| 232 | mutex_lock(&dir->d_inode->i_mutex); | 232 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); |
| 233 | while (!list_empty(&names)) { | 233 | while (!list_empty(&names)) { |
| 234 | entry = list_entry(names.next, struct name_list, list); | 234 | entry = list_entry(names.next, struct name_list, list); |
| 235 | 235 | ||
| @@ -264,7 +264,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen) | |||
| 264 | 264 | ||
| 265 | dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); | 265 | dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); |
| 266 | 266 | ||
| 267 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); | 267 | mutex_lock_nested(&rec_dir.dentry->d_inode->i_mutex, I_MUTEX_PARENT); |
| 268 | dentry = lookup_one_len(name, rec_dir.dentry, namlen); | 268 | dentry = lookup_one_len(name, rec_dir.dentry, namlen); |
| 269 | if (IS_ERR(dentry)) { | 269 | if (IS_ERR(dentry)) { |
| 270 | status = PTR_ERR(dentry); | 270 | status = PTR_ERR(dentry); |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c65a27b76a9..3b711f5147a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
| @@ -580,7 +580,6 @@ free_session(struct kref *kref) | |||
| 580 | struct nfsd4_cache_entry *e = &ses->se_slots[i].sl_cache_entry; | 580 | struct nfsd4_cache_entry *e = &ses->se_slots[i].sl_cache_entry; |
| 581 | nfsd4_release_respages(e->ce_respages, e->ce_resused); | 581 | nfsd4_release_respages(e->ce_respages, e->ce_resused); |
| 582 | } | 582 | } |
| 583 | kfree(ses->se_slots); | ||
| 584 | kfree(ses); | 583 | kfree(ses); |
| 585 | } | 584 | } |
| 586 | 585 | ||
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b820c311931..b73549d293b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
| @@ -2214,6 +2214,15 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, | |||
| 2214 | dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen); | 2214 | dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen); |
| 2215 | if (IS_ERR(dentry)) | 2215 | if (IS_ERR(dentry)) |
| 2216 | return nfserrno(PTR_ERR(dentry)); | 2216 | return nfserrno(PTR_ERR(dentry)); |
| 2217 | if (!dentry->d_inode) { | ||
| 2218 | /* | ||
| 2219 | * nfsd_buffered_readdir drops the i_mutex between | ||
| 2220 | * readdir and calling this callback, leaving a window | ||
| 2221 | * where this directory entry could have gone away. | ||
| 2222 | */ | ||
| 2223 | dput(dentry); | ||
| 2224 | return nfserr_noent; | ||
| 2225 | } | ||
| 2217 | 2226 | ||
| 2218 | exp_get(exp); | 2227 | exp_get(exp); |
| 2219 | /* | 2228 | /* |
| @@ -2276,6 +2285,7 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, | |||
| 2276 | struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common); | 2285 | struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common); |
| 2277 | int buflen; | 2286 | int buflen; |
| 2278 | __be32 *p = cd->buffer; | 2287 | __be32 *p = cd->buffer; |
| 2288 | __be32 *cookiep; | ||
| 2279 | __be32 nfserr = nfserr_toosmall; | 2289 | __be32 nfserr = nfserr_toosmall; |
| 2280 | 2290 | ||
| 2281 | /* In nfsv4, "." and ".." never make it onto the wire.. */ | 2291 | /* In nfsv4, "." and ".." never make it onto the wire.. */ |
| @@ -2292,7 +2302,7 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, | |||
| 2292 | goto fail; | 2302 | goto fail; |
| 2293 | 2303 | ||
| 2294 | *p++ = xdr_one; /* mark entry present */ | 2304 | *p++ = xdr_one; /* mark entry present */ |
| 2295 | cd->offset = p; /* remember pointer */ | 2305 | cookiep = p; |
| 2296 | p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ | 2306 | p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ |
| 2297 | p = xdr_encode_array(p, name, namlen); /* name length & name */ | 2307 | p = xdr_encode_array(p, name, namlen); /* name length & name */ |
| 2298 | 2308 | ||
| @@ -2306,6 +2316,8 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, | |||
| 2306 | goto fail; | 2316 | goto fail; |
| 2307 | case nfserr_dropit: | 2317 | case nfserr_dropit: |
| 2308 | goto fail; | 2318 | goto fail; |
| 2319 | case nfserr_noent: | ||
| 2320 | goto skip_entry; | ||
| 2309 | default: | 2321 | default: |
| 2310 | /* | 2322 | /* |
| 2311 | * If the client requested the RDATTR_ERROR attribute, | 2323 | * If the client requested the RDATTR_ERROR attribute, |
| @@ -2324,6 +2336,8 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, | |||
| 2324 | } | 2336 | } |
| 2325 | cd->buflen -= (p - cd->buffer); | 2337 | cd->buflen -= (p - cd->buffer); |
| 2326 | cd->buffer = p; | 2338 | cd->buffer = p; |
| 2339 | cd->offset = cookiep; | ||
| 2340 | skip_entry: | ||
| 2327 | cd->common.err = nfs_ok; | 2341 | cd->common.err = nfs_ok; |
| 2328 | return 0; | 2342 | return 0; |
| 2329 | fail: | 2343 | fail: |
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 108d281ebca..50ff3f2cdf2 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */ | 25 | #include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */ |
| 26 | #include <linux/capability.h> /* capable() */ | 26 | #include <linux/capability.h> /* capable() */ |
| 27 | #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ | 27 | #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ |
| 28 | #include <linux/vmalloc.h> | ||
| 28 | #include <linux/nilfs2_fs.h> | 29 | #include <linux/nilfs2_fs.h> |
| 29 | #include "nilfs.h" | 30 | #include "nilfs.h" |
| 30 | #include "segment.h" | 31 | #include "segment.h" |
| @@ -147,29 +148,12 @@ static ssize_t | |||
| 147 | nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, | 148 | nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, |
| 148 | void *buf, size_t size, size_t nmembs) | 149 | void *buf, size_t size, size_t nmembs) |
| 149 | { | 150 | { |
| 150 | return nilfs_cpfile_get_cpinfo(nilfs->ns_cpfile, posp, flags, buf, | ||
| 151 | nmembs); | ||
| 152 | } | ||
| 153 | |||
| 154 | static int nilfs_ioctl_get_cpinfo(struct inode *inode, struct file *filp, | ||
| 155 | unsigned int cmd, void __user *argp) | ||
| 156 | { | ||
| 157 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | ||
| 158 | struct nilfs_argv argv; | ||
| 159 | int ret; | 151 | int ret; |
| 160 | 152 | ||
| 161 | if (copy_from_user(&argv, argp, sizeof(argv))) | ||
| 162 | return -EFAULT; | ||
| 163 | |||
| 164 | down_read(&nilfs->ns_segctor_sem); | 153 | down_read(&nilfs->ns_segctor_sem); |
| 165 | ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), | 154 | ret = nilfs_cpfile_get_cpinfo(nilfs->ns_cpfile, posp, flags, buf, |
| 166 | nilfs_ioctl_do_get_cpinfo); | 155 | nmembs); |
| 167 | up_read(&nilfs->ns_segctor_sem); | 156 | up_read(&nilfs->ns_segctor_sem); |
| 168 | if (ret < 0) | ||
| 169 | return ret; | ||
| 170 | |||
| 171 | if (copy_to_user(argp, &argv, sizeof(argv))) | ||
| 172 | ret = -EFAULT; | ||
| 173 | return ret; | 157 | return ret; |
| 174 | } | 158 | } |
| 175 | 159 | ||
| @@ -195,28 +179,11 @@ static ssize_t | |||
| 195 | nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, | 179 | nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, |
| 196 | void *buf, size_t size, size_t nmembs) | 180 | void *buf, size_t size, size_t nmembs) |
| 197 | { | 181 | { |
| 198 | return nilfs_sufile_get_suinfo(nilfs->ns_sufile, *posp, buf, nmembs); | ||
| 199 | } | ||
| 200 | |||
| 201 | static int nilfs_ioctl_get_suinfo(struct inode *inode, struct file *filp, | ||
| 202 | unsigned int cmd, void __user *argp) | ||
| 203 | { | ||
| 204 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | ||
| 205 | struct nilfs_argv argv; | ||
| 206 | int ret; | 182 | int ret; |
| 207 | 183 | ||
| 208 | if (copy_from_user(&argv, argp, sizeof(argv))) | ||
| 209 | return -EFAULT; | ||
| 210 | |||
| 211 | down_read(&nilfs->ns_segctor_sem); | 184 | down_read(&nilfs->ns_segctor_sem); |
| 212 | ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), | 185 | ret = nilfs_sufile_get_suinfo(nilfs->ns_sufile, *posp, buf, nmembs); |
| 213 | nilfs_ioctl_do_get_suinfo); | ||
| 214 | up_read(&nilfs->ns_segctor_sem); | 186 | up_read(&nilfs->ns_segctor_sem); |
| 215 | if (ret < 0) | ||
| 216 | return ret; | ||
| 217 | |||
| 218 | if (copy_to_user(argp, &argv, sizeof(argv))) | ||
| 219 | ret = -EFAULT; | ||
| 220 | return ret; | 187 | return ret; |
| 221 | } | 188 | } |
| 222 | 189 | ||
| @@ -242,28 +209,11 @@ static ssize_t | |||
| 242 | nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, | 209 | nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, |
| 243 | void *buf, size_t size, size_t nmembs) | 210 | void *buf, size_t size, size_t nmembs) |
| 244 | { | 211 | { |
| 245 | return nilfs_dat_get_vinfo(nilfs_dat_inode(nilfs), buf, nmembs); | ||
| 246 | } | ||
| 247 | |||
| 248 | static int nilfs_ioctl_get_vinfo(struct inode *inode, struct file *filp, | ||
| 249 | unsigned int cmd, void __user *argp) | ||
| 250 | { | ||
| 251 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | ||
| 252 | struct nilfs_argv argv; | ||
| 253 | int ret; | 212 | int ret; |
| 254 | 213 | ||
| 255 | if (copy_from_user(&argv, argp, sizeof(argv))) | ||
| 256 | return -EFAULT; | ||
| 257 | |||
| 258 | down_read(&nilfs->ns_segctor_sem); | 214 | down_read(&nilfs->ns_segctor_sem); |
| 259 | ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), | 215 | ret = nilfs_dat_get_vinfo(nilfs_dat_inode(nilfs), buf, nmembs); |
| 260 | nilfs_ioctl_do_get_vinfo); | ||
| 261 | up_read(&nilfs->ns_segctor_sem); | 216 | up_read(&nilfs->ns_segctor_sem); |
| 262 | if (ret < 0) | ||
| 263 | return ret; | ||
| 264 | |||
| 265 | if (copy_to_user(argp, &argv, sizeof(argv))) | ||
| 266 | ret = -EFAULT; | ||
| 267 | return ret; | 217 | return ret; |
| 268 | } | 218 | } |
| 269 | 219 | ||
| @@ -276,17 +226,21 @@ nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags, | |||
| 276 | struct nilfs_bdesc *bdescs = buf; | 226 | struct nilfs_bdesc *bdescs = buf; |
| 277 | int ret, i; | 227 | int ret, i; |
| 278 | 228 | ||
| 229 | down_read(&nilfs->ns_segctor_sem); | ||
| 279 | for (i = 0; i < nmembs; i++) { | 230 | for (i = 0; i < nmembs; i++) { |
| 280 | ret = nilfs_bmap_lookup_at_level(bmap, | 231 | ret = nilfs_bmap_lookup_at_level(bmap, |
| 281 | bdescs[i].bd_offset, | 232 | bdescs[i].bd_offset, |
| 282 | bdescs[i].bd_level + 1, | 233 | bdescs[i].bd_level + 1, |
| 283 | &bdescs[i].bd_blocknr); | 234 | &bdescs[i].bd_blocknr); |
| 284 | if (ret < 0) { | 235 | if (ret < 0) { |
| 285 | if (ret != -ENOENT) | 236 | if (ret != -ENOENT) { |
| 237 | up_read(&nilfs->ns_segctor_sem); | ||
| 286 | return ret; | 238 | return ret; |
| 239 | } | ||
| 287 | bdescs[i].bd_blocknr = 0; | 240 | bdescs[i].bd_blocknr = 0; |
| 288 | } | 241 | } |
| 289 | } | 242 | } |
| 243 | up_read(&nilfs->ns_segctor_sem); | ||
| 290 | return nmembs; | 244 | return nmembs; |
| 291 | } | 245 | } |
| 292 | 246 | ||
| @@ -300,10 +254,11 @@ static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp, | |||
| 300 | if (copy_from_user(&argv, argp, sizeof(argv))) | 254 | if (copy_from_user(&argv, argp, sizeof(argv))) |
| 301 | return -EFAULT; | 255 | return -EFAULT; |
| 302 | 256 | ||
| 303 | down_read(&nilfs->ns_segctor_sem); | 257 | if (argv.v_size != sizeof(struct nilfs_bdesc)) |
| 258 | return -EINVAL; | ||
| 259 | |||
| 304 | ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), | 260 | ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), |
| 305 | nilfs_ioctl_do_get_bdescs); | 261 | nilfs_ioctl_do_get_bdescs); |
| 306 | up_read(&nilfs->ns_segctor_sem); | ||
| 307 | if (ret < 0) | 262 | if (ret < 0) |
| 308 | return ret; | 263 | return ret; |
| 309 | 264 | ||
| @@ -346,10 +301,10 @@ static int nilfs_ioctl_move_inode_block(struct inode *inode, | |||
| 346 | return 0; | 301 | return 0; |
| 347 | } | 302 | } |
| 348 | 303 | ||
| 349 | static ssize_t | 304 | static int nilfs_ioctl_move_blocks(struct the_nilfs *nilfs, |
| 350 | nilfs_ioctl_do_move_blocks(struct the_nilfs *nilfs, __u64 *posp, int flags, | 305 | struct nilfs_argv *argv, void *buf) |
| 351 | void *buf, size_t size, size_t nmembs) | ||
| 352 | { | 306 | { |
| 307 | size_t nmembs = argv->v_nmembs; | ||
| 353 | struct inode *inode; | 308 | struct inode *inode; |
| 354 | struct nilfs_vdesc *vdesc; | 309 | struct nilfs_vdesc *vdesc; |
| 355 | struct buffer_head *bh, *n; | 310 | struct buffer_head *bh, *n; |
| @@ -410,19 +365,10 @@ nilfs_ioctl_do_move_blocks(struct the_nilfs *nilfs, __u64 *posp, int flags, | |||
| 410 | return ret; | 365 | return ret; |
| 411 | } | 366 | } |
| 412 | 367 | ||
| 413 | static inline int nilfs_ioctl_move_blocks(struct the_nilfs *nilfs, | 368 | static int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs, |
| 414 | struct nilfs_argv *argv, | 369 | struct nilfs_argv *argv, void *buf) |
| 415 | int dir) | ||
| 416 | { | ||
| 417 | return nilfs_ioctl_wrap_copy(nilfs, argv, dir, | ||
| 418 | nilfs_ioctl_do_move_blocks); | ||
| 419 | } | ||
| 420 | |||
| 421 | static ssize_t | ||
| 422 | nilfs_ioctl_do_delete_checkpoints(struct the_nilfs *nilfs, __u64 *posp, | ||
| 423 | int flags, void *buf, size_t size, | ||
| 424 | size_t nmembs) | ||
| 425 | { | 370 | { |
| 371 | size_t nmembs = argv->v_nmembs; | ||
| 426 | struct inode *cpfile = nilfs->ns_cpfile; | 372 | struct inode *cpfile = nilfs->ns_cpfile; |
| 427 | struct nilfs_period *periods = buf; | 373 | struct nilfs_period *periods = buf; |
| 428 | int ret, i; | 374 | int ret, i; |
| @@ -436,36 +382,21 @@ nilfs_ioctl_do_delete_checkpoints(struct the_nilfs *nilfs, __u64 *posp, | |||
| 436 | return nmembs; | 382 | return nmembs; |
| 437 | } | 383 | } |
| 438 | 384 | ||
| 439 | static inline int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs, | 385 | static int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs, |
| 440 | struct nilfs_argv *argv, | 386 | struct nilfs_argv *argv, void *buf) |
| 441 | int dir) | ||
| 442 | { | 387 | { |
| 443 | return nilfs_ioctl_wrap_copy(nilfs, argv, dir, | 388 | size_t nmembs = argv->v_nmembs; |
| 444 | nilfs_ioctl_do_delete_checkpoints); | 389 | int ret; |
| 445 | } | ||
| 446 | 390 | ||
| 447 | static ssize_t | 391 | ret = nilfs_dat_freev(nilfs_dat_inode(nilfs), buf, nmembs); |
| 448 | nilfs_ioctl_do_free_vblocknrs(struct the_nilfs *nilfs, __u64 *posp, int flags, | ||
| 449 | void *buf, size_t size, size_t nmembs) | ||
| 450 | { | ||
| 451 | int ret = nilfs_dat_freev(nilfs_dat_inode(nilfs), buf, nmembs); | ||
| 452 | 392 | ||
| 453 | return (ret < 0) ? ret : nmembs; | 393 | return (ret < 0) ? ret : nmembs; |
| 454 | } | 394 | } |
| 455 | 395 | ||
| 456 | static inline int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs, | 396 | static int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs, |
| 457 | struct nilfs_argv *argv, | 397 | struct nilfs_argv *argv, void *buf) |
| 458 | int dir) | ||
| 459 | { | ||
| 460 | return nilfs_ioctl_wrap_copy(nilfs, argv, dir, | ||
| 461 | nilfs_ioctl_do_free_vblocknrs); | ||
| 462 | } | ||
| 463 | |||
| 464 | static ssize_t | ||
| 465 | nilfs_ioctl_do_mark_blocks_dirty(struct the_nilfs *nilfs, __u64 *posp, | ||
| 466 | int flags, void *buf, size_t size, | ||
| 467 | size_t nmembs) | ||
| 468 | { | 398 | { |
| 399 | size_t nmembs = argv->v_nmembs; | ||
| 469 | struct inode *dat = nilfs_dat_inode(nilfs); | 400 | struct inode *dat = nilfs_dat_inode(nilfs); |
| 470 | struct nilfs_bmap *bmap = NILFS_I(dat)->i_bmap; | 401 | struct nilfs_bmap *bmap = NILFS_I(dat)->i_bmap; |
| 471 | struct nilfs_bdesc *bdescs = buf; | 402 | struct nilfs_bdesc *bdescs = buf; |
| @@ -504,55 +435,37 @@ nilfs_ioctl_do_mark_blocks_dirty(struct the_nilfs *nilfs, __u64 *posp, | |||
| 504 | return nmembs; | 435 | return nmembs; |
| 505 | } | 436 | } |
| 506 | 437 | ||
| 507 | static inline int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs, | 438 | static int nilfs_ioctl_free_segments(struct the_nilfs *nilfs, |
| 508 | struct nilfs_argv *argv, | 439 | struct nilfs_argv *argv, void *buf) |
| 509 | int dir) | ||
| 510 | { | 440 | { |
| 511 | return nilfs_ioctl_wrap_copy(nilfs, argv, dir, | 441 | size_t nmembs = argv->v_nmembs; |
| 512 | nilfs_ioctl_do_mark_blocks_dirty); | 442 | struct nilfs_sb_info *sbi = nilfs->ns_writer; |
| 513 | } | ||
| 514 | |||
| 515 | static ssize_t | ||
| 516 | nilfs_ioctl_do_free_segments(struct the_nilfs *nilfs, __u64 *posp, int flags, | ||
| 517 | void *buf, size_t size, size_t nmembs) | ||
| 518 | { | ||
| 519 | struct nilfs_sb_info *sbi = nilfs_get_writer(nilfs); | ||
| 520 | int ret; | 443 | int ret; |
| 521 | 444 | ||
| 522 | if (unlikely(!sbi)) | 445 | if (unlikely(!sbi)) { |
| 446 | /* never happens because called for a writable mount */ | ||
| 447 | WARN_ON(1); | ||
| 523 | return -EROFS; | 448 | return -EROFS; |
| 449 | } | ||
| 524 | ret = nilfs_segctor_add_segments_to_be_freed( | 450 | ret = nilfs_segctor_add_segments_to_be_freed( |
| 525 | NILFS_SC(sbi), buf, nmembs); | 451 | NILFS_SC(sbi), buf, nmembs); |
| 526 | nilfs_put_writer(nilfs); | ||
| 527 | 452 | ||
| 528 | return (ret < 0) ? ret : nmembs; | 453 | return (ret < 0) ? ret : nmembs; |
| 529 | } | 454 | } |
| 530 | 455 | ||
| 531 | static inline int nilfs_ioctl_free_segments(struct the_nilfs *nilfs, | ||
| 532 | struct nilfs_argv *argv, | ||
| 533 | int dir) | ||
| 534 | { | ||
| 535 | return nilfs_ioctl_wrap_copy(nilfs, argv, dir, | ||
| 536 | nilfs_ioctl_do_free_segments); | ||
| 537 | } | ||
| 538 | |||
| 539 | int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, | 456 | int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, |
| 540 | void __user *argp) | 457 | struct nilfs_argv *argv, void **kbufs) |
| 541 | { | 458 | { |
| 542 | struct nilfs_argv argv[5]; | ||
| 543 | const char *msg; | 459 | const char *msg; |
| 544 | int dir, ret; | 460 | int ret; |
| 545 | |||
| 546 | if (copy_from_user(argv, argp, sizeof(argv))) | ||
| 547 | return -EFAULT; | ||
| 548 | 461 | ||
| 549 | dir = _IOC_WRITE; | 462 | ret = nilfs_ioctl_move_blocks(nilfs, &argv[0], kbufs[0]); |
| 550 | ret = nilfs_ioctl_move_blocks(nilfs, &argv[0], dir); | ||
| 551 | if (ret < 0) { | 463 | if (ret < 0) { |
| 552 | msg = "cannot read source blocks"; | 464 | msg = "cannot read source blocks"; |
| 553 | goto failed; | 465 | goto failed; |
| 554 | } | 466 | } |
| 555 | ret = nilfs_ioctl_delete_checkpoints(nilfs, &argv[1], dir); | 467 | |
| 468 | ret = nilfs_ioctl_delete_checkpoints(nilfs, &argv[1], kbufs[1]); | ||
| 556 | if (ret < 0) { | 469 | if (ret < 0) { |
| 557 | /* | 470 | /* |
| 558 | * can safely abort because checkpoints can be removed | 471 | * can safely abort because checkpoints can be removed |
| @@ -561,7 +474,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, | |||
| 561 | msg = "cannot delete checkpoints"; | 474 | msg = "cannot delete checkpoints"; |
| 562 | goto failed; | 475 | goto failed; |
| 563 | } | 476 | } |
| 564 | ret = nilfs_ioctl_free_vblocknrs(nilfs, &argv[2], dir); | 477 | ret = nilfs_ioctl_free_vblocknrs(nilfs, &argv[2], kbufs[2]); |
| 565 | if (ret < 0) { | 478 | if (ret < 0) { |
| 566 | /* | 479 | /* |
| 567 | * can safely abort because DAT file is updated atomically | 480 | * can safely abort because DAT file is updated atomically |
| @@ -570,7 +483,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, | |||
| 570 | msg = "cannot delete virtual blocks from DAT file"; | 483 | msg = "cannot delete virtual blocks from DAT file"; |
| 571 | goto failed; | 484 | goto failed; |
| 572 | } | 485 | } |
| 573 | ret = nilfs_ioctl_mark_blocks_dirty(nilfs, &argv[3], dir); | 486 | ret = nilfs_ioctl_mark_blocks_dirty(nilfs, &argv[3], kbufs[3]); |
| 574 | if (ret < 0) { | 487 | if (ret < 0) { |
| 575 | /* | 488 | /* |
| 576 | * can safely abort because the operation is nondestructive. | 489 | * can safely abort because the operation is nondestructive. |
| @@ -578,7 +491,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, | |||
| 578 | msg = "cannot mark copying blocks dirty"; | 491 | msg = "cannot mark copying blocks dirty"; |
| 579 | goto failed; | 492 | goto failed; |
| 580 | } | 493 | } |
| 581 | ret = nilfs_ioctl_free_segments(nilfs, &argv[4], dir); | 494 | ret = nilfs_ioctl_free_segments(nilfs, &argv[4], kbufs[4]); |
| 582 | if (ret < 0) { | 495 | if (ret < 0) { |
| 583 | /* | 496 | /* |
| 584 | * can safely abort because this operation is atomic. | 497 | * can safely abort because this operation is atomic. |
| @@ -598,9 +511,75 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, | |||
| 598 | static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp, | 511 | static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp, |
| 599 | unsigned int cmd, void __user *argp) | 512 | unsigned int cmd, void __user *argp) |
| 600 | { | 513 | { |
| 514 | struct nilfs_argv argv[5]; | ||
| 515 | const static size_t argsz[5] = { | ||
| 516 | sizeof(struct nilfs_vdesc), | ||
| 517 | sizeof(struct nilfs_period), | ||
| 518 | sizeof(__u64), | ||
| 519 | sizeof(struct nilfs_bdesc), | ||
| 520 | sizeof(__u64), | ||
| 521 | }; | ||
| 522 | void __user *base; | ||
| 523 | void *kbufs[5]; | ||
| 524 | struct the_nilfs *nilfs; | ||
| 525 | size_t len, nsegs; | ||
| 526 | int n, ret; | ||
| 527 | |||
| 601 | if (!capable(CAP_SYS_ADMIN)) | 528 | if (!capable(CAP_SYS_ADMIN)) |
| 602 | return -EPERM; | 529 | return -EPERM; |
| 603 | return nilfs_clean_segments(inode->i_sb, argp); | 530 | |
| 531 | if (copy_from_user(argv, argp, sizeof(argv))) | ||
| 532 | return -EFAULT; | ||
| 533 | |||
| 534 | nsegs = argv[4].v_nmembs; | ||
| 535 | if (argv[4].v_size != argsz[4]) | ||
| 536 | return -EINVAL; | ||
| 537 | /* | ||
| 538 | * argv[4] points to segment numbers this ioctl cleans. We | ||
| 539 | * use kmalloc() for its buffer because memory used for the | ||
| 540 | * segment numbers is enough small. | ||
| 541 | */ | ||
| 542 | kbufs[4] = memdup_user((void __user *)(unsigned long)argv[4].v_base, | ||
| 543 | nsegs * sizeof(__u64)); | ||
| 544 | if (IS_ERR(kbufs[4])) | ||
| 545 | return PTR_ERR(kbufs[4]); | ||
| 546 | |||
| 547 | nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | ||
| 548 | |||
| 549 | for (n = 0; n < 4; n++) { | ||
| 550 | ret = -EINVAL; | ||
| 551 | if (argv[n].v_size != argsz[n]) | ||
| 552 | goto out_free; | ||
| 553 | |||
| 554 | if (argv[n].v_nmembs > nsegs * nilfs->ns_blocks_per_segment) | ||
| 555 | goto out_free; | ||
| 556 | |||
| 557 | len = argv[n].v_size * argv[n].v_nmembs; | ||
| 558 | base = (void __user *)(unsigned long)argv[n].v_base; | ||
| 559 | if (len == 0) { | ||
| 560 | kbufs[n] = NULL; | ||
| 561 | continue; | ||
| 562 | } | ||
| 563 | |||
| 564 | kbufs[n] = vmalloc(len); | ||
| 565 | if (!kbufs[n]) { | ||
| 566 | ret = -ENOMEM; | ||
| 567 | goto out_free; | ||
| 568 | } | ||
| 569 | if (copy_from_user(kbufs[n], base, len)) { | ||
| 570 | ret = -EFAULT; | ||
| 571 | vfree(kbufs[n]); | ||
| 572 | goto out_free; | ||
| 573 | } | ||
| 574 | } | ||
| 575 | |||
| 576 | ret = nilfs_clean_segments(inode->i_sb, argv, kbufs); | ||
| 577 | |||
| 578 | out_free: | ||
| 579 | while (--n > 0) | ||
| 580 | vfree(kbufs[n]); | ||
| 581 | kfree(kbufs[4]); | ||
| 582 | return ret; | ||
| 604 | } | 583 | } |
| 605 | 584 | ||
| 606 | static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, | 585 | static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, |
| @@ -621,6 +600,33 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, | |||
| 621 | return 0; | 600 | return 0; |
| 622 | } | 601 | } |
| 623 | 602 | ||
| 603 | static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp, | ||
| 604 | unsigned int cmd, void __user *argp, | ||
| 605 | size_t membsz, | ||
| 606 | ssize_t (*dofunc)(struct the_nilfs *, | ||
| 607 | __u64 *, int, | ||
| 608 | void *, size_t, size_t)) | ||
| 609 | |||
| 610 | { | ||
| 611 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | ||
| 612 | struct nilfs_argv argv; | ||
| 613 | int ret; | ||
| 614 | |||
| 615 | if (copy_from_user(&argv, argp, sizeof(argv))) | ||
| 616 | return -EFAULT; | ||
| 617 | |||
| 618 | if (argv.v_size != membsz) | ||
| 619 | return -EINVAL; | ||
| 620 | |||
| 621 | ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), dofunc); | ||
| 622 | if (ret < 0) | ||
| 623 | return ret; | ||
| 624 | |||
| 625 | if (copy_to_user(argp, &argv, sizeof(argv))) | ||
| 626 | ret = -EFAULT; | ||
| 627 | return ret; | ||
| 628 | } | ||
| 629 | |||
| 624 | long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 630 | long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
| 625 | { | 631 | { |
| 626 | struct inode *inode = filp->f_dentry->d_inode; | 632 | struct inode *inode = filp->f_dentry->d_inode; |
| @@ -632,16 +638,21 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
| 632 | case NILFS_IOCTL_DELETE_CHECKPOINT: | 638 | case NILFS_IOCTL_DELETE_CHECKPOINT: |
| 633 | return nilfs_ioctl_delete_checkpoint(inode, filp, cmd, argp); | 639 | return nilfs_ioctl_delete_checkpoint(inode, filp, cmd, argp); |
| 634 | case NILFS_IOCTL_GET_CPINFO: | 640 | case NILFS_IOCTL_GET_CPINFO: |
| 635 | return nilfs_ioctl_get_cpinfo(inode, filp, cmd, argp); | 641 | return nilfs_ioctl_get_info(inode, filp, cmd, argp, |
| 642 | sizeof(struct nilfs_cpinfo), | ||
| 643 | nilfs_ioctl_do_get_cpinfo); | ||
| 636 | case NILFS_IOCTL_GET_CPSTAT: | 644 | case NILFS_IOCTL_GET_CPSTAT: |
| 637 | return nilfs_ioctl_get_cpstat(inode, filp, cmd, argp); | 645 | return nilfs_ioctl_get_cpstat(inode, filp, cmd, argp); |
| 638 | case NILFS_IOCTL_GET_SUINFO: | 646 | case NILFS_IOCTL_GET_SUINFO: |
| 639 | return nilfs_ioctl_get_suinfo(inode, filp, cmd, argp); | 647 | return nilfs_ioctl_get_info(inode, filp, cmd, argp, |
| 648 | sizeof(struct nilfs_suinfo), | ||
| 649 | nilfs_ioctl_do_get_suinfo); | ||
| 640 | case NILFS_IOCTL_GET_SUSTAT: | 650 | case NILFS_IOCTL_GET_SUSTAT: |
| 641 | return nilfs_ioctl_get_sustat(inode, filp, cmd, argp); | 651 | return nilfs_ioctl_get_sustat(inode, filp, cmd, argp); |
| 642 | case NILFS_IOCTL_GET_VINFO: | 652 | case NILFS_IOCTL_GET_VINFO: |
| 643 | /* XXX: rename to ??? */ | 653 | return nilfs_ioctl_get_info(inode, filp, cmd, argp, |
| 644 | return nilfs_ioctl_get_vinfo(inode, filp, cmd, argp); | 654 | sizeof(struct nilfs_vinfo), |
| 655 | nilfs_ioctl_do_get_vinfo); | ||
| 645 | case NILFS_IOCTL_GET_BDESCS: | 656 | case NILFS_IOCTL_GET_BDESCS: |
| 646 | return nilfs_ioctl_get_bdescs(inode, filp, cmd, argp); | 657 | return nilfs_ioctl_get_bdescs(inode, filp, cmd, argp); |
| 647 | case NILFS_IOCTL_CLEAN_SEGMENTS: | 658 | case NILFS_IOCTL_CLEAN_SEGMENTS: |
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index 47dd815433f..bb78745a0e3 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c | |||
| @@ -77,19 +77,22 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, | |||
| 77 | void *)) | 77 | void *)) |
| 78 | { | 78 | { |
| 79 | struct the_nilfs *nilfs = NILFS_MDT(inode)->mi_nilfs; | 79 | struct the_nilfs *nilfs = NILFS_MDT(inode)->mi_nilfs; |
| 80 | struct nilfs_sb_info *writer = NULL; | ||
| 81 | struct super_block *sb = inode->i_sb; | 80 | struct super_block *sb = inode->i_sb; |
| 82 | struct nilfs_transaction_info ti; | 81 | struct nilfs_transaction_info ti; |
| 83 | struct buffer_head *bh; | 82 | struct buffer_head *bh; |
| 84 | int err; | 83 | int err; |
| 85 | 84 | ||
| 86 | if (!sb) { | 85 | if (!sb) { |
| 87 | writer = nilfs_get_writer(nilfs); | 86 | /* |
| 88 | if (!writer) { | 87 | * Make sure this function is not called from any |
| 88 | * read-only context. | ||
| 89 | */ | ||
| 90 | if (!nilfs->ns_writer) { | ||
| 91 | WARN_ON(1); | ||
| 89 | err = -EROFS; | 92 | err = -EROFS; |
| 90 | goto out; | 93 | goto out; |
| 91 | } | 94 | } |
| 92 | sb = writer->s_super; | 95 | sb = nilfs->ns_writer->s_super; |
| 93 | } | 96 | } |
| 94 | 97 | ||
| 95 | nilfs_transaction_begin(sb, &ti, 0); | 98 | nilfs_transaction_begin(sb, &ti, 0); |
| @@ -127,8 +130,6 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, | |||
| 127 | err = nilfs_transaction_commit(sb); | 130 | err = nilfs_transaction_commit(sb); |
| 128 | else | 131 | else |
| 129 | nilfs_transaction_abort(sb); | 132 | nilfs_transaction_abort(sb); |
| 130 | if (writer) | ||
| 131 | nilfs_put_writer(nilfs); | ||
| 132 | out: | 133 | out: |
| 133 | return err; | 134 | return err; |
| 134 | } | 135 | } |
| @@ -299,7 +300,7 @@ int nilfs_mdt_delete_block(struct inode *inode, unsigned long block) | |||
| 299 | int err; | 300 | int err; |
| 300 | 301 | ||
| 301 | err = nilfs_bmap_delete(ii->i_bmap, block); | 302 | err = nilfs_bmap_delete(ii->i_bmap, block); |
| 302 | if (likely(!err)) { | 303 | if (!err || err == -ENOENT) { |
| 303 | nilfs_mdt_mark_dirty(inode); | 304 | nilfs_mdt_mark_dirty(inode); |
| 304 | nilfs_mdt_forget_block(inode, block); | 305 | nilfs_mdt_forget_block(inode, block); |
| 305 | } | 306 | } |
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 3d0c18a16db..da6fc0bba2e 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h | |||
| @@ -236,7 +236,8 @@ extern int nilfs_sync_file(struct file *, struct dentry *, int); | |||
| 236 | 236 | ||
| 237 | /* ioctl.c */ | 237 | /* ioctl.c */ |
| 238 | long nilfs_ioctl(struct file *, unsigned int, unsigned long); | 238 | long nilfs_ioctl(struct file *, unsigned int, unsigned long); |
| 239 | int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, void __user *); | 239 | int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *, |
| 240 | void **); | ||
| 240 | 241 | ||
| 241 | /* inode.c */ | 242 | /* inode.c */ |
| 242 | extern struct inode *nilfs_new_inode(struct inode *, int); | 243 | extern struct inode *nilfs_new_inode(struct inode *, int); |
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 1bfbba9c0e9..a2692bbc7b5 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c | |||
| @@ -128,7 +128,8 @@ void nilfs_forget_buffer(struct buffer_head *bh) | |||
| 128 | 128 | ||
| 129 | lock_buffer(bh); | 129 | lock_buffer(bh); |
| 130 | clear_buffer_nilfs_volatile(bh); | 130 | clear_buffer_nilfs_volatile(bh); |
| 131 | if (test_clear_buffer_dirty(bh) && nilfs_page_buffers_clean(page)) | 131 | clear_buffer_dirty(bh); |
| 132 | if (nilfs_page_buffers_clean(page)) | ||
| 132 | __nilfs_clear_page_dirty(page); | 133 | __nilfs_clear_page_dirty(page); |
| 133 | 134 | ||
| 134 | clear_buffer_uptodate(bh); | 135 | clear_buffer_uptodate(bh); |
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c index 4fc081e47d7..57afa9d2406 100644 --- a/fs/nilfs2/recovery.c +++ b/fs/nilfs2/recovery.c | |||
| @@ -407,6 +407,7 @@ void nilfs_dispose_segment_list(struct list_head *head) | |||
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | 409 | static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, |
| 410 | struct nilfs_sb_info *sbi, | ||
| 410 | struct nilfs_recovery_info *ri) | 411 | struct nilfs_recovery_info *ri) |
| 411 | { | 412 | { |
| 412 | struct list_head *head = &ri->ri_used_segments; | 413 | struct list_head *head = &ri->ri_used_segments; |
| @@ -421,6 +422,7 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | |||
| 421 | segnum[2] = ri->ri_segnum; | 422 | segnum[2] = ri->ri_segnum; |
| 422 | segnum[3] = ri->ri_nextnum; | 423 | segnum[3] = ri->ri_nextnum; |
| 423 | 424 | ||
| 425 | nilfs_attach_writer(nilfs, sbi); | ||
| 424 | /* | 426 | /* |
| 425 | * Releasing the next segment of the latest super root. | 427 | * Releasing the next segment of the latest super root. |
| 426 | * The next segment is invalidated by this recovery. | 428 | * The next segment is invalidated by this recovery. |
| @@ -459,10 +461,10 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | |||
| 459 | nilfs->ns_pseg_offset = 0; | 461 | nilfs->ns_pseg_offset = 0; |
| 460 | nilfs->ns_seg_seq = ri->ri_seq + 2; | 462 | nilfs->ns_seg_seq = ri->ri_seq + 2; |
| 461 | nilfs->ns_nextnum = nilfs->ns_segnum = segnum[0]; | 463 | nilfs->ns_nextnum = nilfs->ns_segnum = segnum[0]; |
| 462 | return 0; | ||
| 463 | 464 | ||
| 464 | failed: | 465 | failed: |
| 465 | /* No need to recover sufile because it will be destroyed on error */ | 466 | /* No need to recover sufile because it will be destroyed on error */ |
| 467 | nilfs_detach_writer(nilfs, sbi); | ||
| 466 | return err; | 468 | return err; |
| 467 | } | 469 | } |
| 468 | 470 | ||
| @@ -728,7 +730,7 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs, | |||
| 728 | goto failed; | 730 | goto failed; |
| 729 | 731 | ||
| 730 | if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { | 732 | if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { |
| 731 | err = nilfs_prepare_segment_for_recovery(nilfs, ri); | 733 | err = nilfs_prepare_segment_for_recovery(nilfs, sbi, ri); |
| 732 | if (unlikely(err)) { | 734 | if (unlikely(err)) { |
| 733 | printk(KERN_ERR "NILFS: Error preparing segments for " | 735 | printk(KERN_ERR "NILFS: Error preparing segments for " |
| 734 | "recovery.\n"); | 736 | "recovery.\n"); |
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index fb70ec3be20..22c7f65c240 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
| @@ -2589,7 +2589,8 @@ nilfs_remove_written_gcinodes(struct the_nilfs *nilfs, struct list_head *head) | |||
| 2589 | } | 2589 | } |
| 2590 | } | 2590 | } |
| 2591 | 2591 | ||
| 2592 | int nilfs_clean_segments(struct super_block *sb, void __user *argp) | 2592 | int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, |
| 2593 | void **kbufs) | ||
| 2593 | { | 2594 | { |
| 2594 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2595 | struct nilfs_sb_info *sbi = NILFS_SB(sb); |
| 2595 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2596 | struct nilfs_sc_info *sci = NILFS_SC(sbi); |
| @@ -2606,7 +2607,7 @@ int nilfs_clean_segments(struct super_block *sb, void __user *argp) | |||
| 2606 | err = nilfs_init_gcdat_inode(nilfs); | 2607 | err = nilfs_init_gcdat_inode(nilfs); |
| 2607 | if (unlikely(err)) | 2608 | if (unlikely(err)) |
| 2608 | goto out_unlock; | 2609 | goto out_unlock; |
| 2609 | err = nilfs_ioctl_prepare_clean_segments(nilfs, argp); | 2610 | err = nilfs_ioctl_prepare_clean_segments(nilfs, argv, kbufs); |
| 2610 | if (unlikely(err)) | 2611 | if (unlikely(err)) |
| 2611 | goto out_unlock; | 2612 | goto out_unlock; |
| 2612 | 2613 | ||
diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h index a98fc1ed0bb..476bdd5df5b 100644 --- a/fs/nilfs2/segment.h +++ b/fs/nilfs2/segment.h | |||
| @@ -222,7 +222,8 @@ extern int nilfs_construct_segment(struct super_block *); | |||
| 222 | extern int nilfs_construct_dsync_segment(struct super_block *, struct inode *, | 222 | extern int nilfs_construct_dsync_segment(struct super_block *, struct inode *, |
| 223 | loff_t, loff_t); | 223 | loff_t, loff_t); |
| 224 | extern void nilfs_flush_segment(struct super_block *, ino_t); | 224 | extern void nilfs_flush_segment(struct super_block *, ino_t); |
| 225 | extern int nilfs_clean_segments(struct super_block *, void __user *); | 225 | extern int nilfs_clean_segments(struct super_block *, struct nilfs_argv *, |
| 226 | void **); | ||
| 226 | 227 | ||
| 227 | extern int nilfs_segctor_add_segments_to_be_freed(struct nilfs_sc_info *, | 228 | extern int nilfs_segctor_add_segments_to_be_freed(struct nilfs_sc_info *, |
| 228 | __u64 *, size_t); | 229 | __u64 *, size_t); |
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index ed0a0cfd68d..579dd1b1110 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
| 40 | #include <linux/pagemap.h> | 40 | #include <linux/pagemap.h> |
| 41 | #include <linux/utsname.h> | 41 | #include <linux/utsname.h> |
| 42 | #include <linux/namei.h> | ||
| 42 | 43 | ||
| 43 | #define MLOG_MASK_PREFIX ML_NAMEI | 44 | #define MLOG_MASK_PREFIX ML_NAMEI |
| 44 | #include <cluster/masklog.h> | 45 | #include <cluster/masklog.h> |
| @@ -54,26 +55,6 @@ | |||
| 54 | 55 | ||
| 55 | #include "buffer_head_io.h" | 56 | #include "buffer_head_io.h" |
| 56 | 57 | ||
| 57 | static char *ocfs2_page_getlink(struct dentry * dentry, | ||
| 58 | struct page **ppage); | ||
| 59 | static char *ocfs2_fast_symlink_getlink(struct inode *inode, | ||
| 60 | struct buffer_head **bh); | ||
| 61 | |||
| 62 | /* get the link contents into pagecache */ | ||
| 63 | static char *ocfs2_page_getlink(struct dentry * dentry, | ||
| 64 | struct page **ppage) | ||
| 65 | { | ||
| 66 | struct page * page; | ||
| 67 | struct address_space *mapping = dentry->d_inode->i_mapping; | ||
| 68 | page = read_mapping_page(mapping, 0, NULL); | ||
| 69 | if (IS_ERR(page)) | ||
| 70 | goto sync_fail; | ||
| 71 | *ppage = page; | ||
| 72 | return kmap(page); | ||
| 73 | |||
| 74 | sync_fail: | ||
| 75 | return (char*)page; | ||
| 76 | } | ||
| 77 | 58 | ||
| 78 | static char *ocfs2_fast_symlink_getlink(struct inode *inode, | 59 | static char *ocfs2_fast_symlink_getlink(struct inode *inode, |
| 79 | struct buffer_head **bh) | 60 | struct buffer_head **bh) |
| @@ -128,40 +109,55 @@ out: | |||
| 128 | return ret; | 109 | return ret; |
| 129 | } | 110 | } |
| 130 | 111 | ||
| 131 | static void *ocfs2_follow_link(struct dentry *dentry, | 112 | static void *ocfs2_fast_follow_link(struct dentry *dentry, |
| 132 | struct nameidata *nd) | 113 | struct nameidata *nd) |
| 133 | { | 114 | { |
| 134 | int status; | 115 | int status = 0; |
| 135 | char *link; | 116 | int len; |
| 117 | char *target, *link = ERR_PTR(-ENOMEM); | ||
| 136 | struct inode *inode = dentry->d_inode; | 118 | struct inode *inode = dentry->d_inode; |
| 137 | struct page *page = NULL; | ||
| 138 | struct buffer_head *bh = NULL; | 119 | struct buffer_head *bh = NULL; |
| 139 | 120 | ||
| 140 | if (ocfs2_inode_is_fast_symlink(inode)) | 121 | mlog_entry_void(); |
| 141 | link = ocfs2_fast_symlink_getlink(inode, &bh); | 122 | |
| 142 | else | 123 | BUG_ON(!ocfs2_inode_is_fast_symlink(inode)); |
| 143 | link = ocfs2_page_getlink(dentry, &page); | 124 | target = ocfs2_fast_symlink_getlink(inode, &bh); |
| 144 | if (IS_ERR(link)) { | 125 | if (IS_ERR(target)) { |
| 145 | status = PTR_ERR(link); | 126 | status = PTR_ERR(target); |
| 146 | mlog_errno(status); | 127 | mlog_errno(status); |
| 147 | goto bail; | 128 | goto bail; |
| 148 | } | 129 | } |
| 149 | 130 | ||
| 150 | status = vfs_follow_link(nd, link); | 131 | /* Fast symlinks can't be large */ |
| 132 | len = strlen(target); | ||
| 133 | link = kzalloc(len + 1, GFP_NOFS); | ||
| 134 | if (!link) { | ||
| 135 | status = -ENOMEM; | ||
| 136 | mlog_errno(status); | ||
| 137 | goto bail; | ||
| 138 | } | ||
| 139 | |||
| 140 | memcpy(link, target, len); | ||
| 141 | nd_set_link(nd, link); | ||
| 151 | 142 | ||
| 152 | bail: | 143 | bail: |
| 153 | if (page) { | ||
| 154 | kunmap(page); | ||
| 155 | page_cache_release(page); | ||
| 156 | } | ||
| 157 | brelse(bh); | 144 | brelse(bh); |
| 158 | 145 | ||
| 159 | return ERR_PTR(status); | 146 | mlog_exit(status); |
| 147 | return status ? ERR_PTR(status) : link; | ||
| 148 | } | ||
| 149 | |||
| 150 | static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) | ||
| 151 | { | ||
| 152 | char *link = cookie; | ||
| 153 | |||
| 154 | kfree(link); | ||
| 160 | } | 155 | } |
| 161 | 156 | ||
| 162 | const struct inode_operations ocfs2_symlink_inode_operations = { | 157 | const struct inode_operations ocfs2_symlink_inode_operations = { |
| 163 | .readlink = page_readlink, | 158 | .readlink = page_readlink, |
| 164 | .follow_link = ocfs2_follow_link, | 159 | .follow_link = page_follow_link_light, |
| 160 | .put_link = page_put_link, | ||
| 165 | .getattr = ocfs2_getattr, | 161 | .getattr = ocfs2_getattr, |
| 166 | .setattr = ocfs2_setattr, | 162 | .setattr = ocfs2_setattr, |
| 167 | .setxattr = generic_setxattr, | 163 | .setxattr = generic_setxattr, |
| @@ -171,7 +167,8 @@ const struct inode_operations ocfs2_symlink_inode_operations = { | |||
| 171 | }; | 167 | }; |
| 172 | const struct inode_operations ocfs2_fast_symlink_inode_operations = { | 168 | const struct inode_operations ocfs2_fast_symlink_inode_operations = { |
| 173 | .readlink = ocfs2_readlink, | 169 | .readlink = ocfs2_readlink, |
| 174 | .follow_link = ocfs2_follow_link, | 170 | .follow_link = ocfs2_fast_follow_link, |
| 171 | .put_link = ocfs2_fast_put_link, | ||
| 175 | .getattr = ocfs2_getattr, | 172 | .getattr = ocfs2_getattr, |
| 176 | .setattr = ocfs2_setattr, | 173 | .setattr = ocfs2_setattr, |
| 177 | .setxattr = generic_setxattr, | 174 | .setxattr = generic_setxattr, |
| @@ -1033,7 +1033,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode) | |||
| 1033 | if (!IS_ERR(tmp)) { | 1033 | if (!IS_ERR(tmp)) { |
| 1034 | fd = get_unused_fd_flags(flags); | 1034 | fd = get_unused_fd_flags(flags); |
| 1035 | if (fd >= 0) { | 1035 | if (fd >= 0) { |
| 1036 | struct file *f = do_filp_open(dfd, tmp, flags, mode); | 1036 | struct file *f = do_filp_open(dfd, tmp, flags, mode, 0); |
| 1037 | if (IS_ERR(f)) { | 1037 | if (IS_ERR(f)) { |
| 1038 | put_unused_fd(fd); | 1038 | put_unused_fd(fd); |
| 1039 | fd = PTR_ERR(f); | 1039 | fd = PTR_ERR(f); |
diff --git a/fs/proc/root.c b/fs/proc/root.c index 1e15a2b176e..b080b791d9e 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
| @@ -67,8 +67,7 @@ static int proc_get_sb(struct file_system_type *fs_type, | |||
| 67 | sb->s_flags = flags; | 67 | sb->s_flags = flags; |
| 68 | err = proc_fill_super(sb); | 68 | err = proc_fill_super(sb); |
| 69 | if (err) { | 69 | if (err) { |
| 70 | up_write(&sb->s_umount); | 70 | deactivate_locked_super(sb); |
| 71 | deactivate_super(sb); | ||
| 72 | return err; | 71 | return err; |
| 73 | } | 72 | } |
| 74 | 73 | ||
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c index 67a80d7e59e..45ee3d357c7 100644 --- a/fs/reiserfs/dir.c +++ b/fs/reiserfs/dir.c | |||
| @@ -41,6 +41,18 @@ static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, | |||
| 41 | 41 | ||
| 42 | #define store_ih(where,what) copy_item_head (where, what) | 42 | #define store_ih(where,what) copy_item_head (where, what) |
| 43 | 43 | ||
| 44 | static inline bool is_privroot_deh(struct dentry *dir, | ||
| 45 | struct reiserfs_de_head *deh) | ||
| 46 | { | ||
| 47 | int ret = 0; | ||
| 48 | #ifdef CONFIG_REISERFS_FS_XATTR | ||
| 49 | struct dentry *privroot = REISERFS_SB(dir->d_sb)->priv_root; | ||
| 50 | ret = (dir == dir->d_parent && privroot->d_inode && | ||
| 51 | deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid); | ||
| 52 | #endif | ||
| 53 | return ret; | ||
| 54 | } | ||
| 55 | |||
| 44 | int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent, | 56 | int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent, |
| 45 | filldir_t filldir, loff_t *pos) | 57 | filldir_t filldir, loff_t *pos) |
| 46 | { | 58 | { |
| @@ -138,18 +150,8 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent, | |||
| 138 | } | 150 | } |
| 139 | 151 | ||
| 140 | /* Ignore the .reiserfs_priv entry */ | 152 | /* Ignore the .reiserfs_priv entry */ |
| 141 | if (reiserfs_xattrs(inode->i_sb) && | 153 | if (is_privroot_deh(dentry, deh)) |
| 142 | !old_format_only(inode->i_sb) && | ||
| 143 | dentry == inode->i_sb->s_root && | ||
| 144 | REISERFS_SB(inode->i_sb)->priv_root && | ||
| 145 | REISERFS_SB(inode->i_sb)->priv_root->d_inode | ||
| 146 | && deh_objectid(deh) == | ||
| 147 | le32_to_cpu(INODE_PKEY | ||
| 148 | (REISERFS_SB(inode->i_sb)-> | ||
| 149 | priv_root->d_inode)-> | ||
| 150 | k_objectid)) { | ||
| 151 | continue; | 154 | continue; |
| 152 | } | ||
| 153 | 155 | ||
| 154 | d_off = deh_offset(deh); | 156 | d_off = deh_offset(deh); |
| 155 | *pos = d_off; | 157 | *pos = d_off; |
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index efd4d720718..27157912863 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
| @@ -338,21 +338,8 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 338 | &path_to_entry, &de); | 338 | &path_to_entry, &de); |
| 339 | pathrelse(&path_to_entry); | 339 | pathrelse(&path_to_entry); |
| 340 | if (retval == NAME_FOUND) { | 340 | if (retval == NAME_FOUND) { |
| 341 | /* Hide the .reiserfs_priv directory */ | 341 | inode = reiserfs_iget(dir->i_sb, |
| 342 | if (reiserfs_xattrs(dir->i_sb) && | 342 | (struct cpu_key *)&(de.de_dir_id)); |
| 343 | !old_format_only(dir->i_sb) && | ||
| 344 | REISERFS_SB(dir->i_sb)->priv_root && | ||
| 345 | REISERFS_SB(dir->i_sb)->priv_root->d_inode && | ||
| 346 | de.de_objectid == | ||
| 347 | le32_to_cpu(INODE_PKEY | ||
| 348 | (REISERFS_SB(dir->i_sb)->priv_root->d_inode)-> | ||
| 349 | k_objectid)) { | ||
| 350 | reiserfs_write_unlock(dir->i_sb); | ||
| 351 | return ERR_PTR(-EACCES); | ||
| 352 | } | ||
| 353 | |||
| 354 | inode = | ||
| 355 | reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id)); | ||
| 356 | if (!inode || IS_ERR(inode)) { | 343 | if (!inode || IS_ERR(inode)) { |
| 357 | reiserfs_write_unlock(dir->i_sb); | 344 | reiserfs_write_unlock(dir->i_sb); |
| 358 | return ERR_PTR(-EACCES); | 345 | return ERR_PTR(-EACCES); |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 0ae6486d904..1215a4f50cd 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
| @@ -1316,8 +1316,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
| 1316 | } | 1316 | } |
| 1317 | 1317 | ||
| 1318 | out_ok: | 1318 | out_ok: |
| 1319 | kfree(s->s_options); | 1319 | replace_mount_options(s, new_opts); |
| 1320 | s->s_options = new_opts; | ||
| 1321 | return 0; | 1320 | return 0; |
| 1322 | 1321 | ||
| 1323 | out_err: | 1322 | out_err: |
| @@ -1842,7 +1841,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
| 1842 | goto error; | 1841 | goto error; |
| 1843 | } | 1842 | } |
| 1844 | 1843 | ||
| 1845 | if ((errval = reiserfs_xattr_init(s, s->s_flags))) { | 1844 | if ((errval = reiserfs_lookup_privroot(s)) || |
| 1845 | (errval = reiserfs_xattr_init(s, s->s_flags))) { | ||
| 1846 | dput(s->s_root); | 1846 | dput(s->s_root); |
| 1847 | s->s_root = NULL; | 1847 | s->s_root = NULL; |
| 1848 | goto error; | 1848 | goto error; |
| @@ -1855,7 +1855,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
| 1855 | reiserfs_info(s, "using 3.5.x disk format\n"); | 1855 | reiserfs_info(s, "using 3.5.x disk format\n"); |
| 1856 | } | 1856 | } |
| 1857 | 1857 | ||
| 1858 | if ((errval = reiserfs_xattr_init(s, s->s_flags))) { | 1858 | if ((errval = reiserfs_lookup_privroot(s)) || |
| 1859 | (errval = reiserfs_xattr_init(s, s->s_flags))) { | ||
| 1859 | dput(s->s_root); | 1860 | dput(s->s_root); |
| 1860 | s->s_root = NULL; | 1861 | s->s_root = NULL; |
| 1861 | goto error; | 1862 | goto error; |
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index f83f52bae39..2237e10c7c7 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
| @@ -113,41 +113,28 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 113 | 113 | ||
| 114 | #define xattr_may_create(flags) (!flags || flags & XATTR_CREATE) | 114 | #define xattr_may_create(flags) (!flags || flags & XATTR_CREATE) |
| 115 | 115 | ||
| 116 | /* Returns and possibly creates the xattr dir. */ | 116 | static struct dentry *open_xa_root(struct super_block *sb, int flags) |
| 117 | static struct dentry *lookup_or_create_dir(struct dentry *parent, | ||
| 118 | const char *name, int flags) | ||
| 119 | { | 117 | { |
| 120 | struct dentry *dentry; | 118 | struct dentry *privroot = REISERFS_SB(sb)->priv_root; |
| 121 | BUG_ON(!parent); | 119 | struct dentry *xaroot; |
| 120 | if (!privroot->d_inode) | ||
| 121 | return ERR_PTR(-ENODATA); | ||
| 122 | 122 | ||
| 123 | dentry = lookup_one_len(name, parent, strlen(name)); | 123 | mutex_lock_nested(&privroot->d_inode->i_mutex, I_MUTEX_XATTR); |
| 124 | if (IS_ERR(dentry)) | ||
| 125 | return dentry; | ||
| 126 | else if (!dentry->d_inode) { | ||
| 127 | int err = -ENODATA; | ||
| 128 | |||
| 129 | if (xattr_may_create(flags)) { | ||
| 130 | mutex_lock_nested(&parent->d_inode->i_mutex, | ||
| 131 | I_MUTEX_XATTR); | ||
| 132 | err = xattr_mkdir(parent->d_inode, dentry, 0700); | ||
| 133 | mutex_unlock(&parent->d_inode->i_mutex); | ||
| 134 | } | ||
| 135 | 124 | ||
| 125 | xaroot = dget(REISERFS_SB(sb)->xattr_root); | ||
| 126 | if (!xaroot->d_inode) { | ||
| 127 | int err = -ENODATA; | ||
| 128 | if (xattr_may_create(flags)) | ||
| 129 | err = xattr_mkdir(privroot->d_inode, xaroot, 0700); | ||
| 136 | if (err) { | 130 | if (err) { |
| 137 | dput(dentry); | 131 | dput(xaroot); |
| 138 | dentry = ERR_PTR(err); | 132 | xaroot = ERR_PTR(err); |
| 139 | } | 133 | } |
| 140 | } | 134 | } |
| 141 | 135 | ||
| 142 | return dentry; | 136 | mutex_unlock(&privroot->d_inode->i_mutex); |
| 143 | } | 137 | return xaroot; |
| 144 | |||
| 145 | static struct dentry *open_xa_root(struct super_block *sb, int flags) | ||
| 146 | { | ||
| 147 | struct dentry *privroot = REISERFS_SB(sb)->priv_root; | ||
| 148 | if (!privroot) | ||
| 149 | return ERR_PTR(-ENODATA); | ||
| 150 | return lookup_or_create_dir(privroot, XAROOT_NAME, flags); | ||
| 151 | } | 138 | } |
| 152 | 139 | ||
| 153 | static struct dentry *open_xa_dir(const struct inode *inode, int flags) | 140 | static struct dentry *open_xa_dir(const struct inode *inode, int flags) |
| @@ -163,10 +150,22 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags) | |||
| 163 | le32_to_cpu(INODE_PKEY(inode)->k_objectid), | 150 | le32_to_cpu(INODE_PKEY(inode)->k_objectid), |
| 164 | inode->i_generation); | 151 | inode->i_generation); |
| 165 | 152 | ||
| 166 | xadir = lookup_or_create_dir(xaroot, namebuf, flags); | 153 | mutex_lock_nested(&xaroot->d_inode->i_mutex, I_MUTEX_XATTR); |
| 154 | |||
| 155 | xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf)); | ||
| 156 | if (!IS_ERR(xadir) && !xadir->d_inode) { | ||
| 157 | int err = -ENODATA; | ||
| 158 | if (xattr_may_create(flags)) | ||
| 159 | err = xattr_mkdir(xaroot->d_inode, xadir, 0700); | ||
| 160 | if (err) { | ||
| 161 | dput(xadir); | ||
| 162 | xadir = ERR_PTR(err); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | |||
| 166 | mutex_unlock(&xaroot->d_inode->i_mutex); | ||
| 167 | dput(xaroot); | 167 | dput(xaroot); |
| 168 | return xadir; | 168 | return xadir; |
| 169 | |||
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | /* The following are side effects of other operations that aren't explicitly | 171 | /* The following are side effects of other operations that aren't explicitly |
| @@ -184,6 +183,7 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset, | |||
| 184 | { | 183 | { |
| 185 | struct reiserfs_dentry_buf *dbuf = buf; | 184 | struct reiserfs_dentry_buf *dbuf = buf; |
| 186 | struct dentry *dentry; | 185 | struct dentry *dentry; |
| 186 | WARN_ON_ONCE(!mutex_is_locked(&dbuf->xadir->d_inode->i_mutex)); | ||
| 187 | 187 | ||
| 188 | if (dbuf->count == ARRAY_SIZE(dbuf->dentries)) | 188 | if (dbuf->count == ARRAY_SIZE(dbuf->dentries)) |
| 189 | return -ENOSPC; | 189 | return -ENOSPC; |
| @@ -349,6 +349,7 @@ static struct dentry *xattr_lookup(struct inode *inode, const char *name, | |||
| 349 | if (IS_ERR(xadir)) | 349 | if (IS_ERR(xadir)) |
| 350 | return ERR_CAST(xadir); | 350 | return ERR_CAST(xadir); |
| 351 | 351 | ||
| 352 | mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR); | ||
| 352 | xafile = lookup_one_len(name, xadir, strlen(name)); | 353 | xafile = lookup_one_len(name, xadir, strlen(name)); |
| 353 | if (IS_ERR(xafile)) { | 354 | if (IS_ERR(xafile)) { |
| 354 | err = PTR_ERR(xafile); | 355 | err = PTR_ERR(xafile); |
| @@ -360,18 +361,15 @@ static struct dentry *xattr_lookup(struct inode *inode, const char *name, | |||
| 360 | 361 | ||
| 361 | if (!xafile->d_inode) { | 362 | if (!xafile->d_inode) { |
| 362 | err = -ENODATA; | 363 | err = -ENODATA; |
| 363 | if (xattr_may_create(flags)) { | 364 | if (xattr_may_create(flags)) |
| 364 | mutex_lock_nested(&xadir->d_inode->i_mutex, | ||
| 365 | I_MUTEX_XATTR); | ||
| 366 | err = xattr_create(xadir->d_inode, xafile, | 365 | err = xattr_create(xadir->d_inode, xafile, |
| 367 | 0700|S_IFREG); | 366 | 0700|S_IFREG); |
| 368 | mutex_unlock(&xadir->d_inode->i_mutex); | ||
| 369 | } | ||
| 370 | } | 367 | } |
| 371 | 368 | ||
| 372 | if (err) | 369 | if (err) |
| 373 | dput(xafile); | 370 | dput(xafile); |
| 374 | out: | 371 | out: |
| 372 | mutex_unlock(&xadir->d_inode->i_mutex); | ||
| 375 | dput(xadir); | 373 | dput(xadir); |
| 376 | if (err) | 374 | if (err) |
| 377 | return ERR_PTR(err); | 375 | return ERR_PTR(err); |
| @@ -435,6 +433,7 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name) | |||
| 435 | if (IS_ERR(xadir)) | 433 | if (IS_ERR(xadir)) |
| 436 | return PTR_ERR(xadir); | 434 | return PTR_ERR(xadir); |
| 437 | 435 | ||
| 436 | mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR); | ||
| 438 | dentry = lookup_one_len(name, xadir, strlen(name)); | 437 | dentry = lookup_one_len(name, xadir, strlen(name)); |
| 439 | if (IS_ERR(dentry)) { | 438 | if (IS_ERR(dentry)) { |
| 440 | err = PTR_ERR(dentry); | 439 | err = PTR_ERR(dentry); |
| @@ -442,14 +441,13 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name) | |||
| 442 | } | 441 | } |
| 443 | 442 | ||
| 444 | if (dentry->d_inode) { | 443 | if (dentry->d_inode) { |
| 445 | mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR); | ||
| 446 | err = xattr_unlink(xadir->d_inode, dentry); | 444 | err = xattr_unlink(xadir->d_inode, dentry); |
| 447 | mutex_unlock(&xadir->d_inode->i_mutex); | ||
| 448 | update_ctime(inode); | 445 | update_ctime(inode); |
| 449 | } | 446 | } |
| 450 | 447 | ||
| 451 | dput(dentry); | 448 | dput(dentry); |
| 452 | out_dput: | 449 | out_dput: |
| 450 | mutex_unlock(&xadir->d_inode->i_mutex); | ||
| 453 | dput(xadir); | 451 | dput(xadir); |
| 454 | return err; | 452 | return err; |
| 455 | } | 453 | } |
| @@ -843,7 +841,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) | |||
| 843 | if (!dentry->d_inode) | 841 | if (!dentry->d_inode) |
| 844 | return -EINVAL; | 842 | return -EINVAL; |
| 845 | 843 | ||
| 846 | if (!reiserfs_xattrs(dentry->d_sb) || | 844 | if (!dentry->d_sb->s_xattr || |
| 847 | get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) | 845 | get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
| 848 | return -EOPNOTSUPP; | 846 | return -EOPNOTSUPP; |
| 849 | 847 | ||
| @@ -906,19 +904,22 @@ static int create_privroot(struct dentry *dentry) | |||
| 906 | { | 904 | { |
| 907 | int err; | 905 | int err; |
| 908 | struct inode *inode = dentry->d_parent->d_inode; | 906 | struct inode *inode = dentry->d_parent->d_inode; |
| 909 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR); | 907 | WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex)); |
| 908 | |||
| 910 | err = xattr_mkdir(inode, dentry, 0700); | 909 | err = xattr_mkdir(inode, dentry, 0700); |
| 911 | mutex_unlock(&inode->i_mutex); | 910 | if (err || !dentry->d_inode) { |
| 912 | if (err) { | 911 | reiserfs_warning(dentry->d_sb, "jdm-20006", |
| 913 | dput(dentry); | 912 | "xattrs/ACLs enabled and couldn't " |
| 914 | dentry = NULL; | 913 | "find/create .reiserfs_priv. " |
| 914 | "Failing mount."); | ||
| 915 | return -EOPNOTSUPP; | ||
| 915 | } | 916 | } |
| 916 | 917 | ||
| 917 | if (dentry && dentry->d_inode) | 918 | dentry->d_inode->i_flags |= S_PRIVATE; |
| 918 | reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr " | 919 | reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr " |
| 919 | "storage.\n", PRIVROOT_NAME); | 920 | "storage.\n", PRIVROOT_NAME); |
| 920 | 921 | ||
| 921 | return err; | 922 | return 0; |
| 922 | } | 923 | } |
| 923 | 924 | ||
| 924 | static int xattr_mount_check(struct super_block *s) | 925 | static int xattr_mount_check(struct super_block *s) |
| @@ -950,11 +951,9 @@ static int | |||
| 950 | xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name) | 951 | xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name) |
| 951 | { | 952 | { |
| 952 | struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root; | 953 | struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root; |
| 953 | if (name->len == priv_root->d_name.len && | 954 | if (container_of(q1, struct dentry, d_name) == priv_root) |
| 954 | name->hash == priv_root->d_name.hash && | ||
| 955 | !memcmp(name->name, priv_root->d_name.name, name->len)) { | ||
| 956 | return -ENOENT; | 955 | return -ENOENT; |
| 957 | } else if (q1->len == name->len && | 956 | if (q1->len == name->len && |
| 958 | !memcmp(q1->name, name->name, name->len)) | 957 | !memcmp(q1->name, name->name, name->len)) |
| 959 | return 0; | 958 | return 0; |
| 960 | return 1; | 959 | return 1; |
| @@ -964,59 +963,60 @@ static const struct dentry_operations xattr_lookup_poison_ops = { | |||
| 964 | .d_compare = xattr_lookup_poison, | 963 | .d_compare = xattr_lookup_poison, |
| 965 | }; | 964 | }; |
| 966 | 965 | ||
| 966 | int reiserfs_lookup_privroot(struct super_block *s) | ||
| 967 | { | ||
| 968 | struct dentry *dentry; | ||
| 969 | int err = 0; | ||
| 970 | |||
| 971 | /* If we don't have the privroot located yet - go find it */ | ||
| 972 | mutex_lock(&s->s_root->d_inode->i_mutex); | ||
| 973 | dentry = lookup_one_len(PRIVROOT_NAME, s->s_root, | ||
| 974 | strlen(PRIVROOT_NAME)); | ||
| 975 | if (!IS_ERR(dentry)) { | ||
| 976 | REISERFS_SB(s)->priv_root = dentry; | ||
| 977 | s->s_root->d_op = &xattr_lookup_poison_ops; | ||
| 978 | if (dentry->d_inode) | ||
| 979 | dentry->d_inode->i_flags |= S_PRIVATE; | ||
| 980 | } else | ||
| 981 | err = PTR_ERR(dentry); | ||
| 982 | mutex_unlock(&s->s_root->d_inode->i_mutex); | ||
| 983 | |||
| 984 | return err; | ||
| 985 | } | ||
| 986 | |||
| 967 | /* We need to take a copy of the mount flags since things like | 987 | /* We need to take a copy of the mount flags since things like |
| 968 | * MS_RDONLY don't get set until *after* we're called. | 988 | * MS_RDONLY don't get set until *after* we're called. |
| 969 | * mount_flags != mount_options */ | 989 | * mount_flags != mount_options */ |
| 970 | int reiserfs_xattr_init(struct super_block *s, int mount_flags) | 990 | int reiserfs_xattr_init(struct super_block *s, int mount_flags) |
| 971 | { | 991 | { |
| 972 | int err = 0; | 992 | int err = 0; |
| 993 | struct dentry *privroot = REISERFS_SB(s)->priv_root; | ||
| 973 | 994 | ||
| 974 | #ifdef CONFIG_REISERFS_FS_XATTR | 995 | #ifdef CONFIG_REISERFS_FS_XATTR |
| 975 | err = xattr_mount_check(s); | 996 | err = xattr_mount_check(s); |
| 976 | if (err) | 997 | if (err) |
| 977 | goto error; | 998 | goto error; |
| 978 | #endif | ||
| 979 | 999 | ||
| 980 | /* If we don't have the privroot located yet - go find it */ | 1000 | if (!privroot->d_inode && !(mount_flags & MS_RDONLY)) { |
| 981 | if (!REISERFS_SB(s)->priv_root) { | 1001 | mutex_lock(&s->s_root->d_inode->i_mutex); |
| 982 | struct dentry *dentry; | 1002 | err = create_privroot(REISERFS_SB(s)->priv_root); |
| 983 | dentry = lookup_one_len(PRIVROOT_NAME, s->s_root, | 1003 | mutex_unlock(&s->s_root->d_inode->i_mutex); |
| 984 | strlen(PRIVROOT_NAME)); | ||
| 985 | if (!IS_ERR(dentry)) { | ||
| 986 | #ifdef CONFIG_REISERFS_FS_XATTR | ||
| 987 | if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) | ||
| 988 | err = create_privroot(dentry); | ||
| 989 | #endif | ||
| 990 | if (!dentry->d_inode) { | ||
| 991 | dput(dentry); | ||
| 992 | dentry = NULL; | ||
| 993 | } | ||
| 994 | } else | ||
| 995 | err = PTR_ERR(dentry); | ||
| 996 | |||
| 997 | if (!err && dentry) { | ||
| 998 | s->s_root->d_op = &xattr_lookup_poison_ops; | ||
| 999 | dentry->d_inode->i_flags |= S_PRIVATE; | ||
| 1000 | REISERFS_SB(s)->priv_root = dentry; | ||
| 1001 | #ifdef CONFIG_REISERFS_FS_XATTR | ||
| 1002 | /* xattrs are unavailable */ | ||
| 1003 | } else if (!(mount_flags & MS_RDONLY)) { | ||
| 1004 | /* If we're read-only it just means that the dir | ||
| 1005 | * hasn't been created. Not an error -- just no | ||
| 1006 | * xattrs on the fs. We'll check again if we | ||
| 1007 | * go read-write */ | ||
| 1008 | reiserfs_warning(s, "jdm-20006", | ||
| 1009 | "xattrs/ACLs enabled and couldn't " | ||
| 1010 | "find/create .reiserfs_priv. " | ||
| 1011 | "Failing mount."); | ||
| 1012 | err = -EOPNOTSUPP; | ||
| 1013 | #endif | ||
| 1014 | } | ||
| 1015 | } | 1004 | } |
| 1016 | 1005 | ||
| 1017 | #ifdef CONFIG_REISERFS_FS_XATTR | 1006 | if (privroot->d_inode) { |
| 1018 | if (!err) | ||
| 1019 | s->s_xattr = reiserfs_xattr_handlers; | 1007 | s->s_xattr = reiserfs_xattr_handlers; |
| 1008 | mutex_lock(&privroot->d_inode->i_mutex); | ||
| 1009 | if (!REISERFS_SB(s)->xattr_root) { | ||
| 1010 | struct dentry *dentry; | ||
| 1011 | dentry = lookup_one_len(XAROOT_NAME, privroot, | ||
| 1012 | strlen(XAROOT_NAME)); | ||
| 1013 | if (!IS_ERR(dentry)) | ||
| 1014 | REISERFS_SB(s)->xattr_root = dentry; | ||
| 1015 | else | ||
| 1016 | err = PTR_ERR(dentry); | ||
| 1017 | } | ||
| 1018 | mutex_unlock(&privroot->d_inode->i_mutex); | ||
| 1019 | } | ||
| 1020 | 1020 | ||
| 1021 | error: | 1021 | error: |
| 1022 | if (err) { | 1022 | if (err) { |
| @@ -1026,11 +1026,12 @@ error: | |||
| 1026 | #endif | 1026 | #endif |
| 1027 | 1027 | ||
| 1028 | /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */ | 1028 | /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */ |
| 1029 | s->s_flags = s->s_flags & ~MS_POSIXACL; | ||
| 1030 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL | 1029 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
| 1031 | if (reiserfs_posixacl(s)) | 1030 | if (reiserfs_posixacl(s)) |
| 1032 | s->s_flags |= MS_POSIXACL; | 1031 | s->s_flags |= MS_POSIXACL; |
| 1032 | else | ||
| 1033 | #endif | 1033 | #endif |
| 1034 | s->s_flags &= ~MS_POSIXACL; | ||
| 1034 | 1035 | ||
| 1035 | return err; | 1036 | return err; |
| 1036 | } | 1037 | } |
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index 4d3c20e787c..a92c8792c0f 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c | |||
| @@ -55,8 +55,16 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode, | |||
| 55 | struct reiserfs_security_handle *sec) | 55 | struct reiserfs_security_handle *sec) |
| 56 | { | 56 | { |
| 57 | int blocks = 0; | 57 | int blocks = 0; |
| 58 | int error = security_inode_init_security(inode, dir, &sec->name, | 58 | int error; |
| 59 | &sec->value, &sec->length); | 59 | |
| 60 | sec->name = NULL; | ||
| 61 | |||
| 62 | /* Don't add selinux attributes on xattrs - they'll never get used */ | ||
| 63 | if (IS_PRIVATE(dir)) | ||
| 64 | return 0; | ||
| 65 | |||
| 66 | error = security_inode_init_security(inode, dir, &sec->name, | ||
| 67 | &sec->value, &sec->length); | ||
| 60 | if (error) { | 68 | if (error) { |
| 61 | if (error == -EOPNOTSUPP) | 69 | if (error == -EOPNOTSUPP) |
| 62 | error = 0; | 70 | error = 0; |
diff --git a/fs/romfs/super.c b/fs/romfs/super.c index c53b5ef8a02..4ab3c03d8f9 100644 --- a/fs/romfs/super.c +++ b/fs/romfs/super.c | |||
| @@ -298,7 +298,8 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos) | |||
| 298 | struct romfs_inode ri; | 298 | struct romfs_inode ri; |
| 299 | struct inode *i; | 299 | struct inode *i; |
| 300 | unsigned long nlen; | 300 | unsigned long nlen; |
| 301 | unsigned nextfh, ret; | 301 | unsigned nextfh; |
| 302 | int ret; | ||
| 302 | umode_t mode; | 303 | umode_t mode; |
| 303 | 304 | ||
| 304 | /* we might have to traverse a chain of "hard link" file entries to get | 305 | /* we might have to traverse a chain of "hard link" file entries to get |
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile index 8258cf9a031..70e3244fa30 100644 --- a/fs/squashfs/Makefile +++ b/fs/squashfs/Makefile | |||
| @@ -5,4 +5,3 @@ | |||
| 5 | obj-$(CONFIG_SQUASHFS) += squashfs.o | 5 | obj-$(CONFIG_SQUASHFS) += squashfs.o |
| 6 | squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o | 6 | squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o |
| 7 | squashfs-y += namei.o super.o symlink.o | 7 | squashfs-y += namei.o super.o symlink.o |
| 8 | #squashfs-y += squashfs2_0.o | ||
diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c index 1c4739e33af..40c98fa6b5d 100644 --- a/fs/squashfs/cache.c +++ b/fs/squashfs/cache.c | |||
| @@ -252,6 +252,7 @@ struct squashfs_cache *squashfs_cache_init(char *name, int entries, | |||
| 252 | cache->entries = entries; | 252 | cache->entries = entries; |
| 253 | cache->block_size = block_size; | 253 | cache->block_size = block_size; |
| 254 | cache->pages = block_size >> PAGE_CACHE_SHIFT; | 254 | cache->pages = block_size >> PAGE_CACHE_SHIFT; |
| 255 | cache->pages = cache->pages ? cache->pages : 1; | ||
| 255 | cache->name = name; | 256 | cache->name = name; |
| 256 | cache->num_waiters = 0; | 257 | cache->num_waiters = 0; |
| 257 | spin_lock_init(&cache->lock); | 258 | spin_lock_init(&cache->lock); |
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index ffa6edcd2d0..0adc624c956 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c | |||
| @@ -157,6 +157,16 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 157 | if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE) | 157 | if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE) |
| 158 | goto failed_mount; | 158 | goto failed_mount; |
| 159 | 159 | ||
| 160 | /* | ||
| 161 | * Check the system page size is not larger than the filesystem | ||
| 162 | * block size (by default 128K). This is currently not supported. | ||
| 163 | */ | ||
| 164 | if (PAGE_CACHE_SIZE > msblk->block_size) { | ||
| 165 | ERROR("Page size > filesystem block size (%d). This is " | ||
| 166 | "currently not supported!\n", msblk->block_size); | ||
| 167 | goto failed_mount; | ||
| 168 | } | ||
| 169 | |||
| 160 | msblk->block_log = le16_to_cpu(sblk->block_log); | 170 | msblk->block_log = le16_to_cpu(sblk->block_log); |
| 161 | if (msblk->block_log > SQUASHFS_FILE_MAX_LOG) | 171 | if (msblk->block_log > SQUASHFS_FILE_MAX_LOG) |
| 162 | goto failed_mount; | 172 | goto failed_mount; |
diff --git a/fs/super.c b/fs/super.c index 786fe7d7279..1943fdf655f 100644 --- a/fs/super.c +++ b/fs/super.c | |||
| @@ -208,6 +208,34 @@ void deactivate_super(struct super_block *s) | |||
| 208 | EXPORT_SYMBOL(deactivate_super); | 208 | EXPORT_SYMBOL(deactivate_super); |
| 209 | 209 | ||
| 210 | /** | 210 | /** |
| 211 | * deactivate_locked_super - drop an active reference to superblock | ||
| 212 | * @s: superblock to deactivate | ||
| 213 | * | ||
| 214 | * Equivalent of up_write(&s->s_umount); deactivate_super(s);, except that | ||
| 215 | * it does not unlock it until it's all over. As the result, it's safe to | ||
| 216 | * use to dispose of new superblock on ->get_sb() failure exits - nobody | ||
| 217 | * will see the sucker until it's all over. Equivalent using up_write + | ||
| 218 | * deactivate_super is safe for that purpose only if superblock is either | ||
| 219 | * safe to use or has NULL ->s_root when we unlock. | ||
| 220 | */ | ||
| 221 | void deactivate_locked_super(struct super_block *s) | ||
| 222 | { | ||
| 223 | struct file_system_type *fs = s->s_type; | ||
| 224 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { | ||
| 225 | s->s_count -= S_BIAS-1; | ||
| 226 | spin_unlock(&sb_lock); | ||
| 227 | vfs_dq_off(s, 0); | ||
| 228 | fs->kill_sb(s); | ||
| 229 | put_filesystem(fs); | ||
| 230 | put_super(s); | ||
| 231 | } else { | ||
| 232 | up_write(&s->s_umount); | ||
| 233 | } | ||
| 234 | } | ||
| 235 | |||
| 236 | EXPORT_SYMBOL(deactivate_locked_super); | ||
| 237 | |||
| 238 | /** | ||
| 211 | * grab_super - acquire an active reference | 239 | * grab_super - acquire an active reference |
| 212 | * @s: reference we are trying to make active | 240 | * @s: reference we are trying to make active |
| 213 | * | 241 | * |
| @@ -797,8 +825,7 @@ int get_sb_ns(struct file_system_type *fs_type, int flags, void *data, | |||
| 797 | sb->s_flags = flags; | 825 | sb->s_flags = flags; |
| 798 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); | 826 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); |
| 799 | if (err) { | 827 | if (err) { |
| 800 | up_write(&sb->s_umount); | 828 | deactivate_locked_super(sb); |
| 801 | deactivate_super(sb); | ||
| 802 | return err; | 829 | return err; |
| 803 | } | 830 | } |
| 804 | 831 | ||
| @@ -854,8 +881,7 @@ int get_sb_bdev(struct file_system_type *fs_type, | |||
| 854 | 881 | ||
| 855 | if (s->s_root) { | 882 | if (s->s_root) { |
| 856 | if ((flags ^ s->s_flags) & MS_RDONLY) { | 883 | if ((flags ^ s->s_flags) & MS_RDONLY) { |
| 857 | up_write(&s->s_umount); | 884 | deactivate_locked_super(s); |
| 858 | deactivate_super(s); | ||
| 859 | error = -EBUSY; | 885 | error = -EBUSY; |
| 860 | goto error_bdev; | 886 | goto error_bdev; |
| 861 | } | 887 | } |
| @@ -870,8 +896,7 @@ int get_sb_bdev(struct file_system_type *fs_type, | |||
| 870 | sb_set_blocksize(s, block_size(bdev)); | 896 | sb_set_blocksize(s, block_size(bdev)); |
| 871 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 897 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
| 872 | if (error) { | 898 | if (error) { |
| 873 | up_write(&s->s_umount); | 899 | deactivate_locked_super(s); |
| 874 | deactivate_super(s); | ||
| 875 | goto error; | 900 | goto error; |
| 876 | } | 901 | } |
| 877 | 902 | ||
| @@ -897,7 +922,7 @@ void kill_block_super(struct super_block *sb) | |||
| 897 | struct block_device *bdev = sb->s_bdev; | 922 | struct block_device *bdev = sb->s_bdev; |
| 898 | fmode_t mode = sb->s_mode; | 923 | fmode_t mode = sb->s_mode; |
| 899 | 924 | ||
| 900 | bdev->bd_super = 0; | 925 | bdev->bd_super = NULL; |
| 901 | generic_shutdown_super(sb); | 926 | generic_shutdown_super(sb); |
| 902 | sync_blockdev(bdev); | 927 | sync_blockdev(bdev); |
| 903 | close_bdev_exclusive(bdev, mode); | 928 | close_bdev_exclusive(bdev, mode); |
| @@ -921,8 +946,7 @@ int get_sb_nodev(struct file_system_type *fs_type, | |||
| 921 | 946 | ||
| 922 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 947 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
| 923 | if (error) { | 948 | if (error) { |
| 924 | up_write(&s->s_umount); | 949 | deactivate_locked_super(s); |
| 925 | deactivate_super(s); | ||
| 926 | return error; | 950 | return error; |
| 927 | } | 951 | } |
| 928 | s->s_flags |= MS_ACTIVE; | 952 | s->s_flags |= MS_ACTIVE; |
| @@ -952,8 +976,7 @@ int get_sb_single(struct file_system_type *fs_type, | |||
| 952 | s->s_flags = flags; | 976 | s->s_flags = flags; |
| 953 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 977 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
| 954 | if (error) { | 978 | if (error) { |
| 955 | up_write(&s->s_umount); | 979 | deactivate_locked_super(s); |
| 956 | deactivate_super(s); | ||
| 957 | return error; | 980 | return error; |
| 958 | } | 981 | } |
| 959 | s->s_flags |= MS_ACTIVE; | 982 | s->s_flags |= MS_ACTIVE; |
| @@ -1006,8 +1029,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void | |||
| 1006 | return mnt; | 1029 | return mnt; |
| 1007 | out_sb: | 1030 | out_sb: |
| 1008 | dput(mnt->mnt_root); | 1031 | dput(mnt->mnt_root); |
| 1009 | up_write(&mnt->mnt_sb->s_umount); | 1032 | deactivate_locked_super(mnt->mnt_sb); |
| 1010 | deactivate_super(mnt->mnt_sb); | ||
| 1011 | out_free_secdata: | 1033 | out_free_secdata: |
| 1012 | free_secdata(secdata); | 1034 | free_secdata(secdata); |
| 1013 | out_mnt: | 1035 | out_mnt: |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index faa44f90608..e9f7a754c4f 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
| @@ -2055,8 +2055,7 @@ static int ubifs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 2055 | return 0; | 2055 | return 0; |
| 2056 | 2056 | ||
| 2057 | out_deact: | 2057 | out_deact: |
| 2058 | up_write(&sb->s_umount); | 2058 | deactivate_locked_super(sb); |
| 2059 | deactivate_super(sb); | ||
| 2060 | out_close: | 2059 | out_close: |
| 2061 | ubi_close_volume(ubi); | 2060 | ubi_close_volume(ubi); |
| 2062 | return err; | 2061 | return err; |
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index dbbbc466876..6321b797061 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c | |||
| @@ -666,6 +666,6 @@ not_empty: | |||
| 666 | const struct file_operations ufs_dir_operations = { | 666 | const struct file_operations ufs_dir_operations = { |
| 667 | .read = generic_read_dir, | 667 | .read = generic_read_dir, |
| 668 | .readdir = ufs_readdir, | 668 | .readdir = ufs_readdir, |
| 669 | .fsync = file_fsync, | 669 | .fsync = ufs_sync_file, |
| 670 | .llseek = generic_file_llseek, | 670 | .llseek = generic_file_llseek, |
| 671 | }; | 671 | }; |
diff --git a/fs/ufs/file.c b/fs/ufs/file.c index 625ef17c6f8..2bd3a161571 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | #include "ufs.h" | 30 | #include "ufs.h" |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) | 33 | int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) |
| 34 | { | 34 | { |
| 35 | struct inode *inode = dentry->d_inode; | 35 | struct inode *inode = dentry->d_inode; |
| 36 | int err; | 36 | int err; |
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 69b3427d788..d0c4acd4f1f 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
| @@ -98,8 +98,8 @@ extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, | |||
| 98 | /* file.c */ | 98 | /* file.c */ |
| 99 | extern const struct inode_operations ufs_file_inode_operations; | 99 | extern const struct inode_operations ufs_file_inode_operations; |
| 100 | extern const struct file_operations ufs_file_operations; | 100 | extern const struct file_operations ufs_file_operations; |
| 101 | |||
| 102 | extern const struct address_space_operations ufs_aops; | 101 | extern const struct address_space_operations ufs_aops; |
| 102 | extern int ufs_sync_file(struct file *, struct dentry *, int); | ||
| 103 | 103 | ||
| 104 | /* ialloc.c */ | 104 | /* ialloc.c */ |
| 105 | extern void ufs_free_inode (struct inode *inode); | 105 | extern void ufs_free_inode (struct inode *inode); |
