diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-22 03:12:37 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-22 03:12:37 -0400 |
commit | 8725f25acc656c1522d48a6746055099efdaca4c (patch) | |
tree | e241424fa58178ed6c2a95a4eb931ea83dbea33c /fs | |
parent | c69cccc95fe4b90dde5fe33e6a3b77880b534fa4 (diff) | |
parent | 93ded9b8fd42abe2c3607097963d8de6ad9117eb (diff) |
Merge commit 'origin/master'
Manually fixed up:
drivers/net/fs_enet/fs_enet-main.c
Diffstat (limited to 'fs')
38 files changed, 945 insertions, 757 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index 17216ba99c85..37db79a2ff95 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -470,6 +470,14 @@ config OCFS2_FS_USERSPACE_CLUSTER | |||
470 | It is safe to say Y, as the clustering method is run-time | 470 | It is safe to say Y, as the clustering method is run-time |
471 | selectable. | 471 | selectable. |
472 | 472 | ||
473 | config OCFS2_FS_STATS | ||
474 | bool "OCFS2 statistics" | ||
475 | depends on OCFS2_FS | ||
476 | default y | ||
477 | help | ||
478 | This option allows some fs statistics to be captured. Enabling | ||
479 | this option may increase the memory consumption. | ||
480 | |||
473 | config OCFS2_DEBUG_MASKLOG | 481 | config OCFS2_DEBUG_MASKLOG |
474 | bool "OCFS2 logging support" | 482 | bool "OCFS2 logging support" |
475 | depends on OCFS2_FS | 483 | depends on OCFS2_FS |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index c54eaab71a19..7b3a03c7c6a9 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -58,7 +58,6 @@ | |||
58 | #include <linux/syscalls.h> | 58 | #include <linux/syscalls.h> |
59 | #include <linux/i2c.h> | 59 | #include <linux/i2c.h> |
60 | #include <linux/i2c-dev.h> | 60 | #include <linux/i2c-dev.h> |
61 | #include <linux/wireless.h> | ||
62 | #include <linux/atalk.h> | 61 | #include <linux/atalk.h> |
63 | #include <linux/loop.h> | 62 | #include <linux/loop.h> |
64 | 63 | ||
@@ -1759,64 +1758,6 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a | |||
1759 | return sys_ioctl(fd, cmd, (unsigned long)tdata); | 1758 | return sys_ioctl(fd, cmd, (unsigned long)tdata); |
1760 | } | 1759 | } |
1761 | 1760 | ||
1762 | struct compat_iw_point { | ||
1763 | compat_caddr_t pointer; | ||
1764 | __u16 length; | ||
1765 | __u16 flags; | ||
1766 | }; | ||
1767 | |||
1768 | static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
1769 | { | ||
1770 | struct iwreq __user *iwr; | ||
1771 | struct iwreq __user *iwr_u; | ||
1772 | struct iw_point __user *iwp; | ||
1773 | struct compat_iw_point __user *iwp_u; | ||
1774 | compat_caddr_t pointer_u; | ||
1775 | void __user *pointer; | ||
1776 | __u16 length, flags; | ||
1777 | int ret; | ||
1778 | |||
1779 | iwr_u = compat_ptr(arg); | ||
1780 | iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data; | ||
1781 | iwr = compat_alloc_user_space(sizeof(*iwr)); | ||
1782 | if (iwr == NULL) | ||
1783 | return -ENOMEM; | ||
1784 | |||
1785 | iwp = &iwr->u.data; | ||
1786 | |||
1787 | if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr))) | ||
1788 | return -EFAULT; | ||
1789 | |||
1790 | if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0], | ||
1791 | &iwr_u->ifr_ifrn.ifrn_name[0], | ||
1792 | sizeof(iwr->ifr_ifrn.ifrn_name))) | ||
1793 | return -EFAULT; | ||
1794 | |||
1795 | if (__get_user(pointer_u, &iwp_u->pointer) || | ||
1796 | __get_user(length, &iwp_u->length) || | ||
1797 | __get_user(flags, &iwp_u->flags)) | ||
1798 | return -EFAULT; | ||
1799 | |||
1800 | if (__put_user(compat_ptr(pointer_u), &iwp->pointer) || | ||
1801 | __put_user(length, &iwp->length) || | ||
1802 | __put_user(flags, &iwp->flags)) | ||
1803 | return -EFAULT; | ||
1804 | |||
1805 | ret = sys_ioctl(fd, cmd, (unsigned long) iwr); | ||
1806 | |||
1807 | if (__get_user(pointer, &iwp->pointer) || | ||
1808 | __get_user(length, &iwp->length) || | ||
1809 | __get_user(flags, &iwp->flags)) | ||
1810 | return -EFAULT; | ||
1811 | |||
1812 | if (__put_user(ptr_to_compat(pointer), &iwp_u->pointer) || | ||
1813 | __put_user(length, &iwp_u->length) || | ||
1814 | __put_user(flags, &iwp_u->flags)) | ||
1815 | return -EFAULT; | ||
1816 | |||
1817 | return ret; | ||
1818 | } | ||
1819 | |||
1820 | /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE | 1761 | /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE |
1821 | * for some operations; this forces use of the newer bridge-utils that | 1762 | * for some operations; this forces use of the newer bridge-utils that |
1822 | * use compatiable ioctls | 1763 | * use compatiable ioctls |
@@ -2405,6 +2346,7 @@ COMPATIBLE_IOCTL(HCIGETDEVLIST) | |||
2405 | COMPATIBLE_IOCTL(HCIGETDEVINFO) | 2346 | COMPATIBLE_IOCTL(HCIGETDEVINFO) |
2406 | COMPATIBLE_IOCTL(HCIGETCONNLIST) | 2347 | COMPATIBLE_IOCTL(HCIGETCONNLIST) |
2407 | COMPATIBLE_IOCTL(HCIGETCONNINFO) | 2348 | COMPATIBLE_IOCTL(HCIGETCONNINFO) |
2349 | COMPATIBLE_IOCTL(HCIGETAUTHINFO) | ||
2408 | COMPATIBLE_IOCTL(HCISETRAW) | 2350 | COMPATIBLE_IOCTL(HCISETRAW) |
2409 | COMPATIBLE_IOCTL(HCISETSCAN) | 2351 | COMPATIBLE_IOCTL(HCISETSCAN) |
2410 | COMPATIBLE_IOCTL(HCISETAUTH) | 2352 | COMPATIBLE_IOCTL(HCISETAUTH) |
@@ -2501,36 +2443,6 @@ COMPATIBLE_IOCTL(I2C_TENBIT) | |||
2501 | COMPATIBLE_IOCTL(I2C_PEC) | 2443 | COMPATIBLE_IOCTL(I2C_PEC) |
2502 | COMPATIBLE_IOCTL(I2C_RETRIES) | 2444 | COMPATIBLE_IOCTL(I2C_RETRIES) |
2503 | COMPATIBLE_IOCTL(I2C_TIMEOUT) | 2445 | COMPATIBLE_IOCTL(I2C_TIMEOUT) |
2504 | /* wireless */ | ||
2505 | COMPATIBLE_IOCTL(SIOCSIWCOMMIT) | ||
2506 | COMPATIBLE_IOCTL(SIOCGIWNAME) | ||
2507 | COMPATIBLE_IOCTL(SIOCSIWNWID) | ||
2508 | COMPATIBLE_IOCTL(SIOCGIWNWID) | ||
2509 | COMPATIBLE_IOCTL(SIOCSIWFREQ) | ||
2510 | COMPATIBLE_IOCTL(SIOCGIWFREQ) | ||
2511 | COMPATIBLE_IOCTL(SIOCSIWMODE) | ||
2512 | COMPATIBLE_IOCTL(SIOCGIWMODE) | ||
2513 | COMPATIBLE_IOCTL(SIOCSIWSENS) | ||
2514 | COMPATIBLE_IOCTL(SIOCGIWSENS) | ||
2515 | COMPATIBLE_IOCTL(SIOCSIWRANGE) | ||
2516 | COMPATIBLE_IOCTL(SIOCSIWPRIV) | ||
2517 | COMPATIBLE_IOCTL(SIOCSIWSTATS) | ||
2518 | COMPATIBLE_IOCTL(SIOCSIWAP) | ||
2519 | COMPATIBLE_IOCTL(SIOCGIWAP) | ||
2520 | COMPATIBLE_IOCTL(SIOCSIWRATE) | ||
2521 | COMPATIBLE_IOCTL(SIOCGIWRATE) | ||
2522 | COMPATIBLE_IOCTL(SIOCSIWRTS) | ||
2523 | COMPATIBLE_IOCTL(SIOCGIWRTS) | ||
2524 | COMPATIBLE_IOCTL(SIOCSIWFRAG) | ||
2525 | COMPATIBLE_IOCTL(SIOCGIWFRAG) | ||
2526 | COMPATIBLE_IOCTL(SIOCSIWTXPOW) | ||
2527 | COMPATIBLE_IOCTL(SIOCGIWTXPOW) | ||
2528 | COMPATIBLE_IOCTL(SIOCSIWRETRY) | ||
2529 | COMPATIBLE_IOCTL(SIOCGIWRETRY) | ||
2530 | COMPATIBLE_IOCTL(SIOCSIWPOWER) | ||
2531 | COMPATIBLE_IOCTL(SIOCGIWPOWER) | ||
2532 | COMPATIBLE_IOCTL(SIOCSIWAUTH) | ||
2533 | COMPATIBLE_IOCTL(SIOCGIWAUTH) | ||
2534 | /* hiddev */ | 2446 | /* hiddev */ |
2535 | COMPATIBLE_IOCTL(HIDIOCGVERSION) | 2447 | COMPATIBLE_IOCTL(HIDIOCGVERSION) |
2536 | COMPATIBLE_IOCTL(HIDIOCAPPLICATION) | 2448 | COMPATIBLE_IOCTL(HIDIOCAPPLICATION) |
@@ -2761,29 +2673,7 @@ COMPATIBLE_IOCTL(USBDEVFS_IOCTL32) | |||
2761 | HANDLE_IOCTL(I2C_FUNCS, w_long) | 2673 | HANDLE_IOCTL(I2C_FUNCS, w_long) |
2762 | HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) | 2674 | HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) |
2763 | HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) | 2675 | HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) |
2764 | /* wireless */ | 2676 | /* bridge */ |
2765 | HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl) | ||
2766 | HANDLE_IOCTL(SIOCGIWPRIV, do_wireless_ioctl) | ||
2767 | HANDLE_IOCTL(SIOCGIWSTATS, do_wireless_ioctl) | ||
2768 | HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl) | ||
2769 | HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl) | ||
2770 | HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl) | ||
2771 | HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl) | ||
2772 | HANDLE_IOCTL(SIOCSIWMLME, do_wireless_ioctl) | ||
2773 | HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl) | ||
2774 | HANDLE_IOCTL(SIOCSIWSCAN, do_wireless_ioctl) | ||
2775 | HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl) | ||
2776 | HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl) | ||
2777 | HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl) | ||
2778 | HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl) | ||
2779 | HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl) | ||
2780 | HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl) | ||
2781 | HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl) | ||
2782 | HANDLE_IOCTL(SIOCSIWGENIE, do_wireless_ioctl) | ||
2783 | HANDLE_IOCTL(SIOCGIWGENIE, do_wireless_ioctl) | ||
2784 | HANDLE_IOCTL(SIOCSIWENCODEEXT, do_wireless_ioctl) | ||
2785 | HANDLE_IOCTL(SIOCGIWENCODEEXT, do_wireless_ioctl) | ||
2786 | HANDLE_IOCTL(SIOCSIWPMKSA, do_wireless_ioctl) | ||
2787 | HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl) | 2677 | HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl) |
2788 | HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl) | 2678 | HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl) |
2789 | /* Not implemented in the native kernel */ | 2679 | /* Not implemented in the native kernel */ |
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h index cca98609aa7f..da015c12e3ea 100644 --- a/fs/configfs/configfs_internal.h +++ b/fs/configfs/configfs_internal.h | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/list.h> | 28 | #include <linux/list.h> |
29 | #include <linux/spinlock.h> | ||
29 | 30 | ||
30 | struct configfs_dirent { | 31 | struct configfs_dirent { |
31 | atomic_t s_count; | 32 | atomic_t s_count; |
@@ -47,8 +48,11 @@ struct configfs_dirent { | |||
47 | #define CONFIGFS_USET_DIR 0x0040 | 48 | #define CONFIGFS_USET_DIR 0x0040 |
48 | #define CONFIGFS_USET_DEFAULT 0x0080 | 49 | #define CONFIGFS_USET_DEFAULT 0x0080 |
49 | #define CONFIGFS_USET_DROPPING 0x0100 | 50 | #define CONFIGFS_USET_DROPPING 0x0100 |
51 | #define CONFIGFS_USET_IN_MKDIR 0x0200 | ||
50 | #define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR) | 52 | #define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR) |
51 | 53 | ||
54 | extern spinlock_t configfs_dirent_lock; | ||
55 | |||
52 | extern struct vfsmount * configfs_mount; | 56 | extern struct vfsmount * configfs_mount; |
53 | extern struct kmem_cache *configfs_dir_cachep; | 57 | extern struct kmem_cache *configfs_dir_cachep; |
54 | 58 | ||
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index a48dc7dd8765..179589be063a 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -30,11 +30,25 @@ | |||
30 | #include <linux/mount.h> | 30 | #include <linux/mount.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/err.h> | ||
33 | 34 | ||
34 | #include <linux/configfs.h> | 35 | #include <linux/configfs.h> |
35 | #include "configfs_internal.h" | 36 | #include "configfs_internal.h" |
36 | 37 | ||
37 | DECLARE_RWSEM(configfs_rename_sem); | 38 | DECLARE_RWSEM(configfs_rename_sem); |
39 | /* | ||
40 | * Protects mutations of configfs_dirent linkage together with proper i_mutex | ||
41 | * Also protects mutations of symlinks linkage to target configfs_dirent | ||
42 | * Mutators of configfs_dirent linkage must *both* have the proper inode locked | ||
43 | * and configfs_dirent_lock locked, in that order. | ||
44 | * This allows one to safely traverse configfs_dirent trees and symlinks without | ||
45 | * having to lock inodes. | ||
46 | * | ||
47 | * Protects setting of CONFIGFS_USET_DROPPING: checking the flag | ||
48 | * unlocked is not reliable unless in detach_groups() called from | ||
49 | * rmdir()/unregister() and from configfs_attach_group() | ||
50 | */ | ||
51 | DEFINE_SPINLOCK(configfs_dirent_lock); | ||
38 | 52 | ||
39 | static void configfs_d_iput(struct dentry * dentry, | 53 | static void configfs_d_iput(struct dentry * dentry, |
40 | struct inode * inode) | 54 | struct inode * inode) |
@@ -74,13 +88,20 @@ static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent * pare | |||
74 | 88 | ||
75 | sd = kmem_cache_zalloc(configfs_dir_cachep, GFP_KERNEL); | 89 | sd = kmem_cache_zalloc(configfs_dir_cachep, GFP_KERNEL); |
76 | if (!sd) | 90 | if (!sd) |
77 | return NULL; | 91 | return ERR_PTR(-ENOMEM); |
78 | 92 | ||
79 | atomic_set(&sd->s_count, 1); | 93 | atomic_set(&sd->s_count, 1); |
80 | INIT_LIST_HEAD(&sd->s_links); | 94 | INIT_LIST_HEAD(&sd->s_links); |
81 | INIT_LIST_HEAD(&sd->s_children); | 95 | INIT_LIST_HEAD(&sd->s_children); |
82 | list_add(&sd->s_sibling, &parent_sd->s_children); | ||
83 | sd->s_element = element; | 96 | sd->s_element = element; |
97 | spin_lock(&configfs_dirent_lock); | ||
98 | if (parent_sd->s_type & CONFIGFS_USET_DROPPING) { | ||
99 | spin_unlock(&configfs_dirent_lock); | ||
100 | kmem_cache_free(configfs_dir_cachep, sd); | ||
101 | return ERR_PTR(-ENOENT); | ||
102 | } | ||
103 | list_add(&sd->s_sibling, &parent_sd->s_children); | ||
104 | spin_unlock(&configfs_dirent_lock); | ||
84 | 105 | ||
85 | return sd; | 106 | return sd; |
86 | } | 107 | } |
@@ -118,8 +139,8 @@ int configfs_make_dirent(struct configfs_dirent * parent_sd, | |||
118 | struct configfs_dirent * sd; | 139 | struct configfs_dirent * sd; |
119 | 140 | ||
120 | sd = configfs_new_dirent(parent_sd, element); | 141 | sd = configfs_new_dirent(parent_sd, element); |
121 | if (!sd) | 142 | if (IS_ERR(sd)) |
122 | return -ENOMEM; | 143 | return PTR_ERR(sd); |
123 | 144 | ||
124 | sd->s_mode = mode; | 145 | sd->s_mode = mode; |
125 | sd->s_type = type; | 146 | sd->s_type = type; |
@@ -173,7 +194,9 @@ static int create_dir(struct config_item * k, struct dentry * p, | |||
173 | } else { | 194 | } else { |
174 | struct configfs_dirent *sd = d->d_fsdata; | 195 | struct configfs_dirent *sd = d->d_fsdata; |
175 | if (sd) { | 196 | if (sd) { |
197 | spin_lock(&configfs_dirent_lock); | ||
176 | list_del_init(&sd->s_sibling); | 198 | list_del_init(&sd->s_sibling); |
199 | spin_unlock(&configfs_dirent_lock); | ||
177 | configfs_put(sd); | 200 | configfs_put(sd); |
178 | } | 201 | } |
179 | } | 202 | } |
@@ -224,7 +247,9 @@ int configfs_create_link(struct configfs_symlink *sl, | |||
224 | else { | 247 | else { |
225 | struct configfs_dirent *sd = dentry->d_fsdata; | 248 | struct configfs_dirent *sd = dentry->d_fsdata; |
226 | if (sd) { | 249 | if (sd) { |
250 | spin_lock(&configfs_dirent_lock); | ||
227 | list_del_init(&sd->s_sibling); | 251 | list_del_init(&sd->s_sibling); |
252 | spin_unlock(&configfs_dirent_lock); | ||
228 | configfs_put(sd); | 253 | configfs_put(sd); |
229 | } | 254 | } |
230 | } | 255 | } |
@@ -238,7 +263,9 @@ static void remove_dir(struct dentry * d) | |||
238 | struct configfs_dirent * sd; | 263 | struct configfs_dirent * sd; |
239 | 264 | ||
240 | sd = d->d_fsdata; | 265 | sd = d->d_fsdata; |
266 | spin_lock(&configfs_dirent_lock); | ||
241 | list_del_init(&sd->s_sibling); | 267 | list_del_init(&sd->s_sibling); |
268 | spin_unlock(&configfs_dirent_lock); | ||
242 | configfs_put(sd); | 269 | configfs_put(sd); |
243 | if (d->d_inode) | 270 | if (d->d_inode) |
244 | simple_rmdir(parent->d_inode,d); | 271 | simple_rmdir(parent->d_inode,d); |
@@ -331,13 +358,13 @@ static struct dentry * configfs_lookup(struct inode *dir, | |||
331 | 358 | ||
332 | /* | 359 | /* |
333 | * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are | 360 | * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are |
334 | * attributes and are removed by rmdir(). We recurse, taking i_mutex | 361 | * attributes and are removed by rmdir(). We recurse, setting |
335 | * on all children that are candidates for default detach. If the | 362 | * CONFIGFS_USET_DROPPING on all children that are candidates for |
336 | * result is clean, then configfs_detach_group() will handle dropping | 363 | * default detach. |
337 | * i_mutex. If there is an error, the caller will clean up the i_mutex | 364 | * If there is an error, the caller will reset the flags via |
338 | * holders via configfs_detach_rollback(). | 365 | * configfs_detach_rollback(). |
339 | */ | 366 | */ |
340 | static int configfs_detach_prep(struct dentry *dentry) | 367 | static int configfs_detach_prep(struct dentry *dentry, struct mutex **wait_mutex) |
341 | { | 368 | { |
342 | struct configfs_dirent *parent_sd = dentry->d_fsdata; | 369 | struct configfs_dirent *parent_sd = dentry->d_fsdata; |
343 | struct configfs_dirent *sd; | 370 | struct configfs_dirent *sd; |
@@ -352,15 +379,20 @@ static int configfs_detach_prep(struct dentry *dentry) | |||
352 | if (sd->s_type & CONFIGFS_NOT_PINNED) | 379 | if (sd->s_type & CONFIGFS_NOT_PINNED) |
353 | continue; | 380 | continue; |
354 | if (sd->s_type & CONFIGFS_USET_DEFAULT) { | 381 | if (sd->s_type & CONFIGFS_USET_DEFAULT) { |
355 | mutex_lock(&sd->s_dentry->d_inode->i_mutex); | 382 | /* Abort if racing with mkdir() */ |
356 | /* Mark that we've taken i_mutex */ | 383 | if (sd->s_type & CONFIGFS_USET_IN_MKDIR) { |
384 | if (wait_mutex) | ||
385 | *wait_mutex = &sd->s_dentry->d_inode->i_mutex; | ||
386 | return -EAGAIN; | ||
387 | } | ||
388 | /* Mark that we're trying to drop the group */ | ||
357 | sd->s_type |= CONFIGFS_USET_DROPPING; | 389 | sd->s_type |= CONFIGFS_USET_DROPPING; |
358 | 390 | ||
359 | /* | 391 | /* |
360 | * Yup, recursive. If there's a problem, blame | 392 | * Yup, recursive. If there's a problem, blame |
361 | * deep nesting of default_groups | 393 | * deep nesting of default_groups |
362 | */ | 394 | */ |
363 | ret = configfs_detach_prep(sd->s_dentry); | 395 | ret = configfs_detach_prep(sd->s_dentry, wait_mutex); |
364 | if (!ret) | 396 | if (!ret) |
365 | continue; | 397 | continue; |
366 | } else | 398 | } else |
@@ -374,7 +406,7 @@ out: | |||
374 | } | 406 | } |
375 | 407 | ||
376 | /* | 408 | /* |
377 | * Walk the tree, dropping i_mutex wherever CONFIGFS_USET_DROPPING is | 409 | * Walk the tree, resetting CONFIGFS_USET_DROPPING wherever it was |
378 | * set. | 410 | * set. |
379 | */ | 411 | */ |
380 | static void configfs_detach_rollback(struct dentry *dentry) | 412 | static void configfs_detach_rollback(struct dentry *dentry) |
@@ -385,11 +417,7 @@ static void configfs_detach_rollback(struct dentry *dentry) | |||
385 | list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { | 417 | list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { |
386 | if (sd->s_type & CONFIGFS_USET_DEFAULT) { | 418 | if (sd->s_type & CONFIGFS_USET_DEFAULT) { |
387 | configfs_detach_rollback(sd->s_dentry); | 419 | configfs_detach_rollback(sd->s_dentry); |
388 | 420 | sd->s_type &= ~CONFIGFS_USET_DROPPING; | |
389 | if (sd->s_type & CONFIGFS_USET_DROPPING) { | ||
390 | sd->s_type &= ~CONFIGFS_USET_DROPPING; | ||
391 | mutex_unlock(&sd->s_dentry->d_inode->i_mutex); | ||
392 | } | ||
393 | } | 421 | } |
394 | } | 422 | } |
395 | } | 423 | } |
@@ -410,7 +438,9 @@ static void detach_attrs(struct config_item * item) | |||
410 | list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) { | 438 | list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) { |
411 | if (!sd->s_element || !(sd->s_type & CONFIGFS_NOT_PINNED)) | 439 | if (!sd->s_element || !(sd->s_type & CONFIGFS_NOT_PINNED)) |
412 | continue; | 440 | continue; |
441 | spin_lock(&configfs_dirent_lock); | ||
413 | list_del_init(&sd->s_sibling); | 442 | list_del_init(&sd->s_sibling); |
443 | spin_unlock(&configfs_dirent_lock); | ||
414 | configfs_drop_dentry(sd, dentry); | 444 | configfs_drop_dentry(sd, dentry); |
415 | configfs_put(sd); | 445 | configfs_put(sd); |
416 | } | 446 | } |
@@ -466,16 +496,12 @@ static void detach_groups(struct config_group *group) | |||
466 | 496 | ||
467 | child = sd->s_dentry; | 497 | child = sd->s_dentry; |
468 | 498 | ||
499 | mutex_lock(&child->d_inode->i_mutex); | ||
500 | |||
469 | configfs_detach_group(sd->s_element); | 501 | configfs_detach_group(sd->s_element); |
470 | child->d_inode->i_flags |= S_DEAD; | 502 | child->d_inode->i_flags |= S_DEAD; |
471 | 503 | ||
472 | /* | 504 | mutex_unlock(&child->d_inode->i_mutex); |
473 | * From rmdir/unregister, a configfs_detach_prep() pass | ||
474 | * has taken our i_mutex for us. Drop it. | ||
475 | * From mkdir/register cleanup, there is no sem held. | ||
476 | */ | ||
477 | if (sd->s_type & CONFIGFS_USET_DROPPING) | ||
478 | mutex_unlock(&child->d_inode->i_mutex); | ||
479 | 505 | ||
480 | d_delete(child); | 506 | d_delete(child); |
481 | dput(child); | 507 | dput(child); |
@@ -1001,9 +1027,10 @@ EXPORT_SYMBOL(configfs_undepend_item); | |||
1001 | 1027 | ||
1002 | static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | 1028 | static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
1003 | { | 1029 | { |
1004 | int ret, module_got = 0; | 1030 | int ret = 0; |
1005 | struct config_group *group; | 1031 | int module_got = 0; |
1006 | struct config_item *item; | 1032 | struct config_group *group = NULL; |
1033 | struct config_item *item = NULL; | ||
1007 | struct config_item *parent_item; | 1034 | struct config_item *parent_item; |
1008 | struct configfs_subsystem *subsys; | 1035 | struct configfs_subsystem *subsys; |
1009 | struct configfs_dirent *sd; | 1036 | struct configfs_dirent *sd; |
@@ -1044,28 +1071,32 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1044 | snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); | 1071 | snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); |
1045 | 1072 | ||
1046 | mutex_lock(&subsys->su_mutex); | 1073 | mutex_lock(&subsys->su_mutex); |
1047 | group = NULL; | ||
1048 | item = NULL; | ||
1049 | if (type->ct_group_ops->make_group) { | 1074 | if (type->ct_group_ops->make_group) { |
1050 | group = type->ct_group_ops->make_group(to_config_group(parent_item), name); | 1075 | group = type->ct_group_ops->make_group(to_config_group(parent_item), name); |
1051 | if (group) { | 1076 | if (!group) |
1077 | group = ERR_PTR(-ENOMEM); | ||
1078 | if (!IS_ERR(group)) { | ||
1052 | link_group(to_config_group(parent_item), group); | 1079 | link_group(to_config_group(parent_item), group); |
1053 | item = &group->cg_item; | 1080 | item = &group->cg_item; |
1054 | } | 1081 | } else |
1082 | ret = PTR_ERR(group); | ||
1055 | } else { | 1083 | } else { |
1056 | item = type->ct_group_ops->make_item(to_config_group(parent_item), name); | 1084 | item = type->ct_group_ops->make_item(to_config_group(parent_item), name); |
1057 | if (item) | 1085 | if (!item) |
1086 | item = ERR_PTR(-ENOMEM); | ||
1087 | if (!IS_ERR(item)) | ||
1058 | link_obj(parent_item, item); | 1088 | link_obj(parent_item, item); |
1089 | else | ||
1090 | ret = PTR_ERR(item); | ||
1059 | } | 1091 | } |
1060 | mutex_unlock(&subsys->su_mutex); | 1092 | mutex_unlock(&subsys->su_mutex); |
1061 | 1093 | ||
1062 | kfree(name); | 1094 | kfree(name); |
1063 | if (!item) { | 1095 | if (ret) { |
1064 | /* | 1096 | /* |
1065 | * If item == NULL, then link_obj() was never called. | 1097 | * If item == NULL, then link_obj() was never called. |
1066 | * There are no extra references to clean up. | 1098 | * There are no extra references to clean up. |
1067 | */ | 1099 | */ |
1068 | ret = -ENOMEM; | ||
1069 | goto out_put; | 1100 | goto out_put; |
1070 | } | 1101 | } |
1071 | 1102 | ||
@@ -1093,11 +1124,26 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1093 | */ | 1124 | */ |
1094 | module_got = 1; | 1125 | module_got = 1; |
1095 | 1126 | ||
1127 | /* | ||
1128 | * Make racing rmdir() fail if it did not tag parent with | ||
1129 | * CONFIGFS_USET_DROPPING | ||
1130 | * Note: if CONFIGFS_USET_DROPPING is already set, attach_group() will | ||
1131 | * fail and let rmdir() terminate correctly | ||
1132 | */ | ||
1133 | spin_lock(&configfs_dirent_lock); | ||
1134 | /* This will make configfs_detach_prep() fail */ | ||
1135 | sd->s_type |= CONFIGFS_USET_IN_MKDIR; | ||
1136 | spin_unlock(&configfs_dirent_lock); | ||
1137 | |||
1096 | if (group) | 1138 | if (group) |
1097 | ret = configfs_attach_group(parent_item, item, dentry); | 1139 | ret = configfs_attach_group(parent_item, item, dentry); |
1098 | else | 1140 | else |
1099 | ret = configfs_attach_item(parent_item, item, dentry); | 1141 | ret = configfs_attach_item(parent_item, item, dentry); |
1100 | 1142 | ||
1143 | spin_lock(&configfs_dirent_lock); | ||
1144 | sd->s_type &= ~CONFIGFS_USET_IN_MKDIR; | ||
1145 | spin_unlock(&configfs_dirent_lock); | ||
1146 | |||
1101 | out_unlink: | 1147 | out_unlink: |
1102 | if (ret) { | 1148 | if (ret) { |
1103 | /* Tear down everything we built up */ | 1149 | /* Tear down everything we built up */ |
@@ -1161,12 +1207,27 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1161 | return -EINVAL; | 1207 | return -EINVAL; |
1162 | } | 1208 | } |
1163 | 1209 | ||
1164 | ret = configfs_detach_prep(dentry); | 1210 | spin_lock(&configfs_dirent_lock); |
1165 | if (ret) { | 1211 | do { |
1166 | configfs_detach_rollback(dentry); | 1212 | struct mutex *wait_mutex; |
1167 | config_item_put(parent_item); | 1213 | |
1168 | return ret; | 1214 | ret = configfs_detach_prep(dentry, &wait_mutex); |
1169 | } | 1215 | if (ret) { |
1216 | configfs_detach_rollback(dentry); | ||
1217 | spin_unlock(&configfs_dirent_lock); | ||
1218 | if (ret != -EAGAIN) { | ||
1219 | config_item_put(parent_item); | ||
1220 | return ret; | ||
1221 | } | ||
1222 | |||
1223 | /* Wait until the racing operation terminates */ | ||
1224 | mutex_lock(wait_mutex); | ||
1225 | mutex_unlock(wait_mutex); | ||
1226 | |||
1227 | spin_lock(&configfs_dirent_lock); | ||
1228 | } | ||
1229 | } while (ret == -EAGAIN); | ||
1230 | spin_unlock(&configfs_dirent_lock); | ||
1170 | 1231 | ||
1171 | /* Get a working ref for the duration of this function */ | 1232 | /* Get a working ref for the duration of this function */ |
1172 | item = configfs_get_config_item(dentry); | 1233 | item = configfs_get_config_item(dentry); |
@@ -1258,7 +1319,7 @@ static int configfs_dir_open(struct inode *inode, struct file *file) | |||
1258 | file->private_data = configfs_new_dirent(parent_sd, NULL); | 1319 | file->private_data = configfs_new_dirent(parent_sd, NULL); |
1259 | mutex_unlock(&dentry->d_inode->i_mutex); | 1320 | mutex_unlock(&dentry->d_inode->i_mutex); |
1260 | 1321 | ||
1261 | return file->private_data ? 0 : -ENOMEM; | 1322 | return IS_ERR(file->private_data) ? PTR_ERR(file->private_data) : 0; |
1262 | 1323 | ||
1263 | } | 1324 | } |
1264 | 1325 | ||
@@ -1268,7 +1329,9 @@ static int configfs_dir_close(struct inode *inode, struct file *file) | |||
1268 | struct configfs_dirent * cursor = file->private_data; | 1329 | struct configfs_dirent * cursor = file->private_data; |
1269 | 1330 | ||
1270 | mutex_lock(&dentry->d_inode->i_mutex); | 1331 | mutex_lock(&dentry->d_inode->i_mutex); |
1332 | spin_lock(&configfs_dirent_lock); | ||
1271 | list_del_init(&cursor->s_sibling); | 1333 | list_del_init(&cursor->s_sibling); |
1334 | spin_unlock(&configfs_dirent_lock); | ||
1272 | mutex_unlock(&dentry->d_inode->i_mutex); | 1335 | mutex_unlock(&dentry->d_inode->i_mutex); |
1273 | 1336 | ||
1274 | release_configfs_dirent(cursor); | 1337 | release_configfs_dirent(cursor); |
@@ -1308,7 +1371,9 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir | |||
1308 | /* fallthrough */ | 1371 | /* fallthrough */ |
1309 | default: | 1372 | default: |
1310 | if (filp->f_pos == 2) { | 1373 | if (filp->f_pos == 2) { |
1374 | spin_lock(&configfs_dirent_lock); | ||
1311 | list_move(q, &parent_sd->s_children); | 1375 | list_move(q, &parent_sd->s_children); |
1376 | spin_unlock(&configfs_dirent_lock); | ||
1312 | } | 1377 | } |
1313 | for (p=q->next; p!= &parent_sd->s_children; p=p->next) { | 1378 | for (p=q->next; p!= &parent_sd->s_children; p=p->next) { |
1314 | struct configfs_dirent *next; | 1379 | struct configfs_dirent *next; |
@@ -1331,7 +1396,9 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir | |||
1331 | dt_type(next)) < 0) | 1396 | dt_type(next)) < 0) |
1332 | return 0; | 1397 | return 0; |
1333 | 1398 | ||
1399 | spin_lock(&configfs_dirent_lock); | ||
1334 | list_move(q, p); | 1400 | list_move(q, p); |
1401 | spin_unlock(&configfs_dirent_lock); | ||
1335 | p = q; | 1402 | p = q; |
1336 | filp->f_pos++; | 1403 | filp->f_pos++; |
1337 | } | 1404 | } |
@@ -1362,6 +1429,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin) | |||
1362 | struct list_head *p; | 1429 | struct list_head *p; |
1363 | loff_t n = file->f_pos - 2; | 1430 | loff_t n = file->f_pos - 2; |
1364 | 1431 | ||
1432 | spin_lock(&configfs_dirent_lock); | ||
1365 | list_del(&cursor->s_sibling); | 1433 | list_del(&cursor->s_sibling); |
1366 | p = sd->s_children.next; | 1434 | p = sd->s_children.next; |
1367 | while (n && p != &sd->s_children) { | 1435 | while (n && p != &sd->s_children) { |
@@ -1373,6 +1441,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin) | |||
1373 | p = p->next; | 1441 | p = p->next; |
1374 | } | 1442 | } |
1375 | list_add_tail(&cursor->s_sibling, p); | 1443 | list_add_tail(&cursor->s_sibling, p); |
1444 | spin_unlock(&configfs_dirent_lock); | ||
1376 | } | 1445 | } |
1377 | } | 1446 | } |
1378 | mutex_unlock(&dentry->d_inode->i_mutex); | 1447 | mutex_unlock(&dentry->d_inode->i_mutex); |
@@ -1448,9 +1517,11 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys) | |||
1448 | mutex_lock_nested(&configfs_sb->s_root->d_inode->i_mutex, | 1517 | mutex_lock_nested(&configfs_sb->s_root->d_inode->i_mutex, |
1449 | I_MUTEX_PARENT); | 1518 | I_MUTEX_PARENT); |
1450 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); | 1519 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); |
1451 | if (configfs_detach_prep(dentry)) { | 1520 | spin_lock(&configfs_dirent_lock); |
1521 | if (configfs_detach_prep(dentry, NULL)) { | ||
1452 | printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); | 1522 | printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); |
1453 | } | 1523 | } |
1524 | spin_unlock(&configfs_dirent_lock); | ||
1454 | configfs_detach_group(&group->cg_item); | 1525 | configfs_detach_group(&group->cg_item); |
1455 | dentry->d_inode->i_flags |= S_DEAD; | 1526 | dentry->d_inode->i_flags |= S_DEAD; |
1456 | mutex_unlock(&dentry->d_inode->i_mutex); | 1527 | mutex_unlock(&dentry->d_inode->i_mutex); |
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index b9a1d810346d..4803ccc94480 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c | |||
@@ -247,7 +247,9 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name) | |||
247 | if (!sd->s_element) | 247 | if (!sd->s_element) |
248 | continue; | 248 | continue; |
249 | if (!strcmp(configfs_get_name(sd), name)) { | 249 | if (!strcmp(configfs_get_name(sd), name)) { |
250 | spin_lock(&configfs_dirent_lock); | ||
250 | list_del_init(&sd->s_sibling); | 251 | list_del_init(&sd->s_sibling); |
252 | spin_unlock(&configfs_dirent_lock); | ||
251 | configfs_drop_dentry(sd, dir); | 253 | configfs_drop_dentry(sd, dir); |
252 | configfs_put(sd); | 254 | configfs_put(sd); |
253 | break; | 255 | break; |
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c index 2a731ef5f305..0004d18c40ac 100644 --- a/fs/configfs/symlink.c +++ b/fs/configfs/symlink.c | |||
@@ -77,12 +77,15 @@ static int create_link(struct config_item *parent_item, | |||
77 | sl = kmalloc(sizeof(struct configfs_symlink), GFP_KERNEL); | 77 | sl = kmalloc(sizeof(struct configfs_symlink), GFP_KERNEL); |
78 | if (sl) { | 78 | if (sl) { |
79 | sl->sl_target = config_item_get(item); | 79 | sl->sl_target = config_item_get(item); |
80 | /* FIXME: needs a lock, I'd bet */ | 80 | spin_lock(&configfs_dirent_lock); |
81 | list_add(&sl->sl_list, &target_sd->s_links); | 81 | list_add(&sl->sl_list, &target_sd->s_links); |
82 | spin_unlock(&configfs_dirent_lock); | ||
82 | ret = configfs_create_link(sl, parent_item->ci_dentry, | 83 | ret = configfs_create_link(sl, parent_item->ci_dentry, |
83 | dentry); | 84 | dentry); |
84 | if (ret) { | 85 | if (ret) { |
86 | spin_lock(&configfs_dirent_lock); | ||
85 | list_del_init(&sl->sl_list); | 87 | list_del_init(&sl->sl_list); |
88 | spin_unlock(&configfs_dirent_lock); | ||
86 | config_item_put(item); | 89 | config_item_put(item); |
87 | kfree(sl); | 90 | kfree(sl); |
88 | } | 91 | } |
@@ -137,8 +140,12 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna | |||
137 | goto out_put; | 140 | goto out_put; |
138 | 141 | ||
139 | ret = type->ct_item_ops->allow_link(parent_item, target_item); | 142 | ret = type->ct_item_ops->allow_link(parent_item, target_item); |
140 | if (!ret) | 143 | if (!ret) { |
141 | ret = create_link(parent_item, target_item, dentry); | 144 | ret = create_link(parent_item, target_item, dentry); |
145 | if (ret && type->ct_item_ops->drop_link) | ||
146 | type->ct_item_ops->drop_link(parent_item, | ||
147 | target_item); | ||
148 | } | ||
142 | 149 | ||
143 | config_item_put(target_item); | 150 | config_item_put(target_item); |
144 | path_put(&nd.path); | 151 | path_put(&nd.path); |
@@ -169,7 +176,9 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry) | |||
169 | parent_item = configfs_get_config_item(dentry->d_parent); | 176 | parent_item = configfs_get_config_item(dentry->d_parent); |
170 | type = parent_item->ci_type; | 177 | type = parent_item->ci_type; |
171 | 178 | ||
179 | spin_lock(&configfs_dirent_lock); | ||
172 | list_del_init(&sd->s_sibling); | 180 | list_del_init(&sd->s_sibling); |
181 | spin_unlock(&configfs_dirent_lock); | ||
173 | configfs_drop_dentry(sd, dentry->d_parent); | 182 | configfs_drop_dentry(sd, dentry->d_parent); |
174 | dput(dentry); | 183 | dput(dentry); |
175 | configfs_put(sd); | 184 | configfs_put(sd); |
@@ -184,8 +193,9 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry) | |||
184 | type->ct_item_ops->drop_link(parent_item, | 193 | type->ct_item_ops->drop_link(parent_item, |
185 | sl->sl_target); | 194 | sl->sl_target); |
186 | 195 | ||
187 | /* FIXME: Needs lock */ | 196 | spin_lock(&configfs_dirent_lock); |
188 | list_del_init(&sl->sl_list); | 197 | list_del_init(&sl->sl_list); |
198 | spin_unlock(&configfs_dirent_lock); | ||
189 | 199 | ||
190 | /* Put reference from create_link() */ | 200 | /* Put reference from create_link() */ |
191 | config_item_put(sl->sl_target); | 201 | config_item_put(sl->sl_target); |
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index eac23bd288b2..c4e7d721bd8d 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -438,7 +438,7 @@ static struct config_group *make_cluster(struct config_group *g, | |||
438 | kfree(gps); | 438 | kfree(gps); |
439 | kfree(sps); | 439 | kfree(sps); |
440 | kfree(cms); | 440 | kfree(cms); |
441 | return NULL; | 441 | return ERR_PTR(-ENOMEM); |
442 | } | 442 | } |
443 | 443 | ||
444 | static void drop_cluster(struct config_group *g, struct config_item *i) | 444 | static void drop_cluster(struct config_group *g, struct config_item *i) |
@@ -495,7 +495,7 @@ static struct config_group *make_space(struct config_group *g, const char *name) | |||
495 | kfree(sp); | 495 | kfree(sp); |
496 | kfree(gps); | 496 | kfree(gps); |
497 | kfree(nds); | 497 | kfree(nds); |
498 | return NULL; | 498 | return ERR_PTR(-ENOMEM); |
499 | } | 499 | } |
500 | 500 | ||
501 | static void drop_space(struct config_group *g, struct config_item *i) | 501 | static void drop_space(struct config_group *g, struct config_item *i) |
@@ -528,7 +528,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name) | |||
528 | 528 | ||
529 | cm = kzalloc(sizeof(struct comm), GFP_KERNEL); | 529 | cm = kzalloc(sizeof(struct comm), GFP_KERNEL); |
530 | if (!cm) | 530 | if (!cm) |
531 | return NULL; | 531 | return ERR_PTR(-ENOMEM); |
532 | 532 | ||
533 | config_item_init_type_name(&cm->item, name, &comm_type); | 533 | config_item_init_type_name(&cm->item, name, &comm_type); |
534 | cm->nodeid = -1; | 534 | cm->nodeid = -1; |
@@ -561,7 +561,7 @@ static struct config_item *make_node(struct config_group *g, const char *name) | |||
561 | 561 | ||
562 | nd = kzalloc(sizeof(struct node), GFP_KERNEL); | 562 | nd = kzalloc(sizeof(struct node), GFP_KERNEL); |
563 | if (!nd) | 563 | if (!nd) |
564 | return NULL; | 564 | return ERR_PTR(-ENOMEM); |
565 | 565 | ||
566 | config_item_init_type_name(&nd->item, name, &node_type); | 566 | config_item_init_type_name(&nd->item, name, &node_type); |
567 | nd->nodeid = -1; | 567 | nd->nodeid = -1; |
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 2169af4d5455..5bd9bf0fa9df 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -50,7 +50,7 @@ EXPORT_SYMBOL(nlmsvc_ops); | |||
50 | static DEFINE_MUTEX(nlmsvc_mutex); | 50 | static DEFINE_MUTEX(nlmsvc_mutex); |
51 | static unsigned int nlmsvc_users; | 51 | static unsigned int nlmsvc_users; |
52 | static struct task_struct *nlmsvc_task; | 52 | static struct task_struct *nlmsvc_task; |
53 | static struct svc_serv *nlmsvc_serv; | 53 | static struct svc_rqst *nlmsvc_rqst; |
54 | int nlmsvc_grace_period; | 54 | int nlmsvc_grace_period; |
55 | unsigned long nlmsvc_timeout; | 55 | unsigned long nlmsvc_timeout; |
56 | 56 | ||
@@ -194,20 +194,11 @@ lockd(void *vrqstp) | |||
194 | 194 | ||
195 | svc_process(rqstp); | 195 | svc_process(rqstp); |
196 | } | 196 | } |
197 | |||
198 | flush_signals(current); | 197 | flush_signals(current); |
199 | if (nlmsvc_ops) | 198 | if (nlmsvc_ops) |
200 | nlmsvc_invalidate_all(); | 199 | nlmsvc_invalidate_all(); |
201 | nlm_shutdown_hosts(); | 200 | nlm_shutdown_hosts(); |
202 | |||
203 | unlock_kernel(); | 201 | unlock_kernel(); |
204 | |||
205 | nlmsvc_task = NULL; | ||
206 | nlmsvc_serv = NULL; | ||
207 | |||
208 | /* Exit the RPC thread */ | ||
209 | svc_exit_thread(rqstp); | ||
210 | |||
211 | return 0; | 202 | return 0; |
212 | } | 203 | } |
213 | 204 | ||
@@ -254,16 +245,15 @@ int | |||
254 | lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */ | 245 | lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */ |
255 | { | 246 | { |
256 | struct svc_serv *serv; | 247 | struct svc_serv *serv; |
257 | struct svc_rqst *rqstp; | ||
258 | int error = 0; | 248 | int error = 0; |
259 | 249 | ||
260 | mutex_lock(&nlmsvc_mutex); | 250 | mutex_lock(&nlmsvc_mutex); |
261 | /* | 251 | /* |
262 | * Check whether we're already up and running. | 252 | * Check whether we're already up and running. |
263 | */ | 253 | */ |
264 | if (nlmsvc_serv) { | 254 | if (nlmsvc_rqst) { |
265 | if (proto) | 255 | if (proto) |
266 | error = make_socks(nlmsvc_serv, proto); | 256 | error = make_socks(nlmsvc_rqst->rq_server, proto); |
267 | goto out; | 257 | goto out; |
268 | } | 258 | } |
269 | 259 | ||
@@ -288,9 +278,10 @@ lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */ | |||
288 | /* | 278 | /* |
289 | * Create the kernel thread and wait for it to start. | 279 | * Create the kernel thread and wait for it to start. |
290 | */ | 280 | */ |
291 | rqstp = svc_prepare_thread(serv, &serv->sv_pools[0]); | 281 | nlmsvc_rqst = svc_prepare_thread(serv, &serv->sv_pools[0]); |
292 | if (IS_ERR(rqstp)) { | 282 | if (IS_ERR(nlmsvc_rqst)) { |
293 | error = PTR_ERR(rqstp); | 283 | error = PTR_ERR(nlmsvc_rqst); |
284 | nlmsvc_rqst = NULL; | ||
294 | printk(KERN_WARNING | 285 | printk(KERN_WARNING |
295 | "lockd_up: svc_rqst allocation failed, error=%d\n", | 286 | "lockd_up: svc_rqst allocation failed, error=%d\n", |
296 | error); | 287 | error); |
@@ -298,16 +289,15 @@ lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */ | |||
298 | } | 289 | } |
299 | 290 | ||
300 | svc_sock_update_bufs(serv); | 291 | svc_sock_update_bufs(serv); |
301 | nlmsvc_serv = rqstp->rq_server; | ||
302 | 292 | ||
303 | nlmsvc_task = kthread_run(lockd, rqstp, serv->sv_name); | 293 | nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name); |
304 | if (IS_ERR(nlmsvc_task)) { | 294 | if (IS_ERR(nlmsvc_task)) { |
305 | error = PTR_ERR(nlmsvc_task); | 295 | error = PTR_ERR(nlmsvc_task); |
296 | svc_exit_thread(nlmsvc_rqst); | ||
306 | nlmsvc_task = NULL; | 297 | nlmsvc_task = NULL; |
307 | nlmsvc_serv = NULL; | 298 | nlmsvc_rqst = NULL; |
308 | printk(KERN_WARNING | 299 | printk(KERN_WARNING |
309 | "lockd_up: kthread_run failed, error=%d\n", error); | 300 | "lockd_up: kthread_run failed, error=%d\n", error); |
310 | svc_exit_thread(rqstp); | ||
311 | goto destroy_and_out; | 301 | goto destroy_and_out; |
312 | } | 302 | } |
313 | 303 | ||
@@ -346,6 +336,9 @@ lockd_down(void) | |||
346 | BUG(); | 336 | BUG(); |
347 | } | 337 | } |
348 | kthread_stop(nlmsvc_task); | 338 | kthread_stop(nlmsvc_task); |
339 | svc_exit_thread(nlmsvc_rqst); | ||
340 | nlmsvc_task = NULL; | ||
341 | nlmsvc_rqst = NULL; | ||
349 | out: | 342 | out: |
350 | mutex_unlock(&nlmsvc_mutex); | 343 | mutex_unlock(&nlmsvc_mutex); |
351 | } | 344 | } |
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 2e27176ff42f..399444639337 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c | |||
@@ -58,8 +58,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
58 | return 0; | 58 | return 0; |
59 | 59 | ||
60 | no_locks: | 60 | no_locks: |
61 | if (host) | 61 | nlm_release_host(host); |
62 | nlm_release_host(host); | ||
63 | if (error) | 62 | if (error) |
64 | return error; | 63 | return error; |
65 | return nlm_lck_denied_nolocks; | 64 | return nlm_lck_denied_nolocks; |
@@ -100,7 +99,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
100 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; | 99 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
101 | 100 | ||
102 | /* Now check for conflicting locks */ | 101 | /* Now check for conflicting locks */ |
103 | resp->status = nlmsvc_testlock(rqstp, file, &argp->lock, &resp->lock, &resp->cookie); | 102 | resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie); |
104 | if (resp->status == nlm_drop_reply) | 103 | if (resp->status == nlm_drop_reply) |
105 | rc = rpc_drop_reply; | 104 | rc = rpc_drop_reply; |
106 | else | 105 | else |
@@ -146,7 +145,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
146 | #endif | 145 | #endif |
147 | 146 | ||
148 | /* Now try to lock the file */ | 147 | /* Now try to lock the file */ |
149 | resp->status = nlmsvc_lock(rqstp, file, &argp->lock, | 148 | resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock, |
150 | argp->block, &argp->cookie); | 149 | argp->block, &argp->cookie); |
151 | if (resp->status == nlm_drop_reply) | 150 | if (resp->status == nlm_drop_reply) |
152 | rc = rpc_drop_reply; | 151 | rc = rpc_drop_reply; |
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 56a08ab9a4cb..821b9acdfb66 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c | |||
@@ -129,9 +129,9 @@ nlmsvc_lookup_block(struct nlm_file *file, struct nlm_lock *lock) | |||
129 | 129 | ||
130 | static inline int nlm_cookie_match(struct nlm_cookie *a, struct nlm_cookie *b) | 130 | static inline int nlm_cookie_match(struct nlm_cookie *a, struct nlm_cookie *b) |
131 | { | 131 | { |
132 | if(a->len != b->len) | 132 | if (a->len != b->len) |
133 | return 0; | 133 | return 0; |
134 | if(memcmp(a->data,b->data,a->len)) | 134 | if (memcmp(a->data, b->data, a->len)) |
135 | return 0; | 135 | return 0; |
136 | return 1; | 136 | return 1; |
137 | } | 137 | } |
@@ -180,6 +180,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host, | |||
180 | struct nlm_block *block; | 180 | struct nlm_block *block; |
181 | struct nlm_rqst *call = NULL; | 181 | struct nlm_rqst *call = NULL; |
182 | 182 | ||
183 | nlm_get_host(host); | ||
183 | call = nlm_alloc_call(host); | 184 | call = nlm_alloc_call(host); |
184 | if (call == NULL) | 185 | if (call == NULL) |
185 | return NULL; | 186 | return NULL; |
@@ -358,10 +359,10 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block) | |||
358 | */ | 359 | */ |
359 | __be32 | 360 | __be32 |
360 | nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, | 361 | nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, |
361 | struct nlm_lock *lock, int wait, struct nlm_cookie *cookie) | 362 | struct nlm_host *host, struct nlm_lock *lock, int wait, |
363 | struct nlm_cookie *cookie) | ||
362 | { | 364 | { |
363 | struct nlm_block *block = NULL; | 365 | struct nlm_block *block = NULL; |
364 | struct nlm_host *host; | ||
365 | int error; | 366 | int error; |
366 | __be32 ret; | 367 | __be32 ret; |
367 | 368 | ||
@@ -373,11 +374,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
373 | (long long)lock->fl.fl_end, | 374 | (long long)lock->fl.fl_end, |
374 | wait); | 375 | wait); |
375 | 376 | ||
376 | /* Create host handle for callback */ | ||
377 | host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len); | ||
378 | if (host == NULL) | ||
379 | return nlm_lck_denied_nolocks; | ||
380 | |||
381 | /* Lock file against concurrent access */ | 377 | /* Lock file against concurrent access */ |
382 | mutex_lock(&file->f_mutex); | 378 | mutex_lock(&file->f_mutex); |
383 | /* Get existing block (in case client is busy-waiting) | 379 | /* Get existing block (in case client is busy-waiting) |
@@ -385,8 +381,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
385 | */ | 381 | */ |
386 | block = nlmsvc_lookup_block(file, lock); | 382 | block = nlmsvc_lookup_block(file, lock); |
387 | if (block == NULL) { | 383 | if (block == NULL) { |
388 | block = nlmsvc_create_block(rqstp, nlm_get_host(host), file, | 384 | block = nlmsvc_create_block(rqstp, host, file, lock, cookie); |
389 | lock, cookie); | ||
390 | ret = nlm_lck_denied_nolocks; | 385 | ret = nlm_lck_denied_nolocks; |
391 | if (block == NULL) | 386 | if (block == NULL) |
392 | goto out; | 387 | goto out; |
@@ -417,7 +412,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
417 | lock->fl.fl_flags &= ~FL_SLEEP; | 412 | lock->fl.fl_flags &= ~FL_SLEEP; |
418 | 413 | ||
419 | dprintk("lockd: vfs_lock_file returned %d\n", error); | 414 | dprintk("lockd: vfs_lock_file returned %d\n", error); |
420 | switch(error) { | 415 | switch (error) { |
421 | case 0: | 416 | case 0: |
422 | ret = nlm_granted; | 417 | ret = nlm_granted; |
423 | goto out; | 418 | goto out; |
@@ -450,7 +445,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
450 | out: | 445 | out: |
451 | mutex_unlock(&file->f_mutex); | 446 | mutex_unlock(&file->f_mutex); |
452 | nlmsvc_release_block(block); | 447 | nlmsvc_release_block(block); |
453 | nlm_release_host(host); | ||
454 | dprintk("lockd: nlmsvc_lock returned %u\n", ret); | 448 | dprintk("lockd: nlmsvc_lock returned %u\n", ret); |
455 | return ret; | 449 | return ret; |
456 | } | 450 | } |
@@ -460,8 +454,8 @@ out: | |||
460 | */ | 454 | */ |
461 | __be32 | 455 | __be32 |
462 | nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, | 456 | nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, |
463 | struct nlm_lock *lock, struct nlm_lock *conflock, | 457 | struct nlm_host *host, struct nlm_lock *lock, |
464 | struct nlm_cookie *cookie) | 458 | struct nlm_lock *conflock, struct nlm_cookie *cookie) |
465 | { | 459 | { |
466 | struct nlm_block *block = NULL; | 460 | struct nlm_block *block = NULL; |
467 | int error; | 461 | int error; |
@@ -479,16 +473,9 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
479 | 473 | ||
480 | if (block == NULL) { | 474 | if (block == NULL) { |
481 | struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL); | 475 | struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL); |
482 | struct nlm_host *host; | ||
483 | 476 | ||
484 | if (conf == NULL) | 477 | if (conf == NULL) |
485 | return nlm_granted; | 478 | return nlm_granted; |
486 | /* Create host handle for callback */ | ||
487 | host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len); | ||
488 | if (host == NULL) { | ||
489 | kfree(conf); | ||
490 | return nlm_lck_denied_nolocks; | ||
491 | } | ||
492 | block = nlmsvc_create_block(rqstp, host, file, lock, cookie); | 479 | block = nlmsvc_create_block(rqstp, host, file, lock, cookie); |
493 | if (block == NULL) { | 480 | if (block == NULL) { |
494 | kfree(conf); | 481 | kfree(conf); |
@@ -897,7 +884,7 @@ nlmsvc_retry_blocked(void) | |||
897 | 884 | ||
898 | if (block->b_when == NLM_NEVER) | 885 | if (block->b_when == NLM_NEVER) |
899 | break; | 886 | break; |
900 | if (time_after(block->b_when,jiffies)) { | 887 | if (time_after(block->b_when, jiffies)) { |
901 | timeout = block->b_when - jiffies; | 888 | timeout = block->b_when - jiffies; |
902 | break; | 889 | break; |
903 | } | 890 | } |
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index ce6952b50a75..76019d2ff72d 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c | |||
@@ -87,8 +87,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
87 | return 0; | 87 | return 0; |
88 | 88 | ||
89 | no_locks: | 89 | no_locks: |
90 | if (host) | 90 | nlm_release_host(host); |
91 | nlm_release_host(host); | ||
92 | if (error) | 91 | if (error) |
93 | return error; | 92 | return error; |
94 | return nlm_lck_denied_nolocks; | 93 | return nlm_lck_denied_nolocks; |
@@ -129,7 +128,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
129 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; | 128 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
130 | 129 | ||
131 | /* Now check for conflicting locks */ | 130 | /* Now check for conflicting locks */ |
132 | resp->status = cast_status(nlmsvc_testlock(rqstp, file, &argp->lock, &resp->lock, &resp->cookie)); | 131 | resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie)); |
133 | if (resp->status == nlm_drop_reply) | 132 | if (resp->status == nlm_drop_reply) |
134 | rc = rpc_drop_reply; | 133 | rc = rpc_drop_reply; |
135 | else | 134 | else |
@@ -176,7 +175,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
176 | #endif | 175 | #endif |
177 | 176 | ||
178 | /* Now try to lock the file */ | 177 | /* Now try to lock the file */ |
179 | resp->status = cast_status(nlmsvc_lock(rqstp, file, &argp->lock, | 178 | resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock, |
180 | argp->block, &argp->cookie)); | 179 | argp->block, &argp->cookie)); |
181 | if (resp->status == nlm_drop_reply) | 180 | if (resp->status == nlm_drop_reply) |
182 | rc = rpc_drop_reply; | 181 | rc = rpc_drop_reply; |
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index d1c48b539df8..198b4e55b373 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c | |||
@@ -373,13 +373,16 @@ nlmsvc_free_host_resources(struct nlm_host *host) | |||
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | /* | 376 | /** |
377 | * Remove all locks held for clients | 377 | * nlmsvc_invalidate_all - remove all locks held for clients |
378 | * | ||
379 | * Release all locks held by NFS clients. | ||
380 | * | ||
378 | */ | 381 | */ |
379 | void | 382 | void |
380 | nlmsvc_invalidate_all(void) | 383 | nlmsvc_invalidate_all(void) |
381 | { | 384 | { |
382 | /* Release all locks held by NFS clients. | 385 | /* |
383 | * Previously, the code would call | 386 | * Previously, the code would call |
384 | * nlmsvc_free_host_resources for each client in | 387 | * nlmsvc_free_host_resources for each client in |
385 | * turn, which is about as inefficient as it gets. | 388 | * turn, which is about as inefficient as it gets. |
@@ -396,6 +399,12 @@ nlmsvc_match_sb(void *datap, struct nlm_file *file) | |||
396 | return sb == file->f_file->f_path.mnt->mnt_sb; | 399 | return sb == file->f_file->f_path.mnt->mnt_sb; |
397 | } | 400 | } |
398 | 401 | ||
402 | /** | ||
403 | * nlmsvc_unlock_all_by_sb - release locks held on this file system | ||
404 | * @sb: super block | ||
405 | * | ||
406 | * Release all locks held by clients accessing this file system. | ||
407 | */ | ||
399 | int | 408 | int |
400 | nlmsvc_unlock_all_by_sb(struct super_block *sb) | 409 | nlmsvc_unlock_all_by_sb(struct super_block *sb) |
401 | { | 410 | { |
@@ -409,17 +418,22 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb); | |||
409 | static int | 418 | static int |
410 | nlmsvc_match_ip(void *datap, struct nlm_host *host) | 419 | nlmsvc_match_ip(void *datap, struct nlm_host *host) |
411 | { | 420 | { |
412 | __be32 *server_addr = datap; | 421 | return nlm_cmp_addr(&host->h_saddr, datap); |
413 | |||
414 | return host->h_saddr.sin_addr.s_addr == *server_addr; | ||
415 | } | 422 | } |
416 | 423 | ||
424 | /** | ||
425 | * nlmsvc_unlock_all_by_ip - release local locks by IP address | ||
426 | * @server_addr: server's IP address as seen by clients | ||
427 | * | ||
428 | * Release all locks held by clients accessing this host | ||
429 | * via the passed in IP address. | ||
430 | */ | ||
417 | int | 431 | int |
418 | nlmsvc_unlock_all_by_ip(__be32 server_addr) | 432 | nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr) |
419 | { | 433 | { |
420 | int ret; | 434 | int ret; |
421 | ret = nlm_traverse_files(&server_addr, nlmsvc_match_ip, NULL); | ||
422 | return ret ? -EIO : 0; | ||
423 | 435 | ||
436 | ret = nlm_traverse_files(server_addr, nlmsvc_match_ip, NULL); | ||
437 | return ret ? -EIO : 0; | ||
424 | } | 438 | } |
425 | EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_ip); | 439 | EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_ip); |
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c index 9e4a568a5013..6b6225ac4926 100644 --- a/fs/nfsd/lockd.c +++ b/fs/nfsd/lockd.c | |||
@@ -35,7 +35,7 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp) | |||
35 | fh.fh_export = NULL; | 35 | fh.fh_export = NULL; |
36 | 36 | ||
37 | exp_readlock(); | 37 | exp_readlock(); |
38 | nfserr = nfsd_open(rqstp, &fh, S_IFREG, MAY_LOCK, filp); | 38 | nfserr = nfsd_open(rqstp, &fh, S_IFREG, NFSD_MAY_LOCK, filp); |
39 | fh_put(&fh); | 39 | fh_put(&fh); |
40 | rqstp->rq_client = NULL; | 40 | rqstp->rq_client = NULL; |
41 | exp_readunlock(); | 41 | exp_readunlock(); |
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 1c3b7654e966..4e3219e84116 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c | |||
@@ -40,7 +40,8 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp, | |||
40 | dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); | 40 | dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); |
41 | 41 | ||
42 | fh = fh_copy(&resp->fh, &argp->fh); | 42 | fh = fh_copy(&resp->fh, &argp->fh); |
43 | if ((nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP))) | 43 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); |
44 | if (nfserr) | ||
44 | RETURN_STATUS(nfserr); | 45 | RETURN_STATUS(nfserr); |
45 | 46 | ||
46 | if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) | 47 | if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) |
@@ -107,7 +108,7 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp, | |||
107 | dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); | 108 | dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); |
108 | 109 | ||
109 | fh = fh_copy(&resp->fh, &argp->fh); | 110 | fh = fh_copy(&resp->fh, &argp->fh); |
110 | nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_SATTR); | 111 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); |
111 | 112 | ||
112 | if (!nfserr) { | 113 | if (!nfserr) { |
113 | nfserr = nfserrno( nfsd_set_posix_acl( | 114 | nfserr = nfserrno( nfsd_set_posix_acl( |
@@ -134,7 +135,7 @@ static __be32 nfsacld_proc_getattr(struct svc_rqst * rqstp, | |||
134 | dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); | 135 | dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); |
135 | 136 | ||
136 | fh_copy(&resp->fh, &argp->fh); | 137 | fh_copy(&resp->fh, &argp->fh); |
137 | return fh_verify(rqstp, &resp->fh, 0, MAY_NOP); | 138 | return fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); |
138 | } | 139 | } |
139 | 140 | ||
140 | /* | 141 | /* |
diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index b647f2f872dc..9981dbb377a3 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c | |||
@@ -36,7 +36,8 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp, | |||
36 | __be32 nfserr = 0; | 36 | __be32 nfserr = 0; |
37 | 37 | ||
38 | fh = fh_copy(&resp->fh, &argp->fh); | 38 | fh = fh_copy(&resp->fh, &argp->fh); |
39 | if ((nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP))) | 39 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); |
40 | if (nfserr) | ||
40 | RETURN_STATUS(nfserr); | 41 | RETURN_STATUS(nfserr); |
41 | 42 | ||
42 | if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) | 43 | if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) |
@@ -101,7 +102,7 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp, | |||
101 | __be32 nfserr = 0; | 102 | __be32 nfserr = 0; |
102 | 103 | ||
103 | fh = fh_copy(&resp->fh, &argp->fh); | 104 | fh = fh_copy(&resp->fh, &argp->fh); |
104 | nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_SATTR); | 105 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); |
105 | 106 | ||
106 | if (!nfserr) { | 107 | if (!nfserr) { |
107 | nfserr = nfserrno( nfsd_set_posix_acl( | 108 | nfserr = nfserrno( nfsd_set_posix_acl( |
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index c721a1e6e9dd..4d617ea28cfc 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c | |||
@@ -63,7 +63,7 @@ nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, | |||
63 | SVCFH_fmt(&argp->fh)); | 63 | SVCFH_fmt(&argp->fh)); |
64 | 64 | ||
65 | fh_copy(&resp->fh, &argp->fh); | 65 | fh_copy(&resp->fh, &argp->fh); |
66 | nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP); | 66 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); |
67 | if (nfserr) | 67 | if (nfserr) |
68 | RETURN_STATUS(nfserr); | 68 | RETURN_STATUS(nfserr); |
69 | 69 | ||
@@ -242,7 +242,7 @@ nfsd3_proc_create(struct svc_rqst *rqstp, struct nfsd3_createargs *argp, | |||
242 | attr = &argp->attrs; | 242 | attr = &argp->attrs; |
243 | 243 | ||
244 | /* Get the directory inode */ | 244 | /* Get the directory inode */ |
245 | nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, MAY_CREATE); | 245 | nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_CREATE); |
246 | if (nfserr) | 246 | if (nfserr) |
247 | RETURN_STATUS(nfserr); | 247 | RETURN_STATUS(nfserr); |
248 | 248 | ||
@@ -558,7 +558,7 @@ nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, | |||
558 | resp->f_maxfilesize = ~(u32) 0; | 558 | resp->f_maxfilesize = ~(u32) 0; |
559 | resp->f_properties = NFS3_FSF_DEFAULT; | 559 | resp->f_properties = NFS3_FSF_DEFAULT; |
560 | 560 | ||
561 | nfserr = fh_verify(rqstp, &argp->fh, 0, MAY_NOP); | 561 | nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
562 | 562 | ||
563 | /* Check special features of the file system. May request | 563 | /* Check special features of the file system. May request |
564 | * different read/write sizes for file systems known to have | 564 | * different read/write sizes for file systems known to have |
@@ -597,7 +597,7 @@ nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle *argp, | |||
597 | resp->p_case_insensitive = 0; | 597 | resp->p_case_insensitive = 0; |
598 | resp->p_case_preserving = 1; | 598 | resp->p_case_preserving = 1; |
599 | 599 | ||
600 | nfserr = fh_verify(rqstp, &argp->fh, 0, MAY_NOP); | 600 | nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
601 | 601 | ||
602 | if (nfserr == 0) { | 602 | if (nfserr == 0) { |
603 | struct super_block *sb = argp->fh.fh_dentry->d_inode->i_sb; | 603 | struct super_block *sb = argp->fh.fh_dentry->d_inode->i_sb; |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index c309c881bd4e..eef1629806f5 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -71,11 +71,11 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs | |||
71 | return nfserr_inval; | 71 | return nfserr_inval; |
72 | 72 | ||
73 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) | 73 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) |
74 | accmode |= MAY_READ; | 74 | accmode |= NFSD_MAY_READ; |
75 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) | 75 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) |
76 | accmode |= (MAY_WRITE | MAY_TRUNC); | 76 | accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC); |
77 | if (open->op_share_deny & NFS4_SHARE_DENY_WRITE) | 77 | if (open->op_share_deny & NFS4_SHARE_DENY_WRITE) |
78 | accmode |= MAY_WRITE; | 78 | accmode |= NFSD_MAY_WRITE; |
79 | 79 | ||
80 | status = fh_verify(rqstp, current_fh, S_IFREG, accmode); | 80 | status = fh_verify(rqstp, current_fh, S_IFREG, accmode); |
81 | 81 | ||
@@ -126,7 +126,8 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o | |||
126 | &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size); | 126 | &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size); |
127 | 127 | ||
128 | if (!created) | 128 | if (!created) |
129 | status = do_open_permission(rqstp, current_fh, open, MAY_NOP); | 129 | status = do_open_permission(rqstp, current_fh, open, |
130 | NFSD_MAY_NOP); | ||
130 | 131 | ||
131 | out: | 132 | out: |
132 | fh_put(&resfh); | 133 | fh_put(&resfh); |
@@ -157,7 +158,8 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ | |||
157 | open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && | 158 | open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && |
158 | (open->op_iattr.ia_size == 0); | 159 | (open->op_iattr.ia_size == 0); |
159 | 160 | ||
160 | status = do_open_permission(rqstp, current_fh, open, MAY_OWNER_OVERRIDE); | 161 | status = do_open_permission(rqstp, current_fh, open, |
162 | NFSD_MAY_OWNER_OVERRIDE); | ||
161 | 163 | ||
162 | return status; | 164 | return status; |
163 | } | 165 | } |
@@ -186,7 +188,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
186 | cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len; | 188 | cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len; |
187 | memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh, | 189 | memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh, |
188 | rp->rp_openfh_len); | 190 | rp->rp_openfh_len); |
189 | status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 191 | status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
190 | if (status) | 192 | if (status) |
191 | dprintk("nfsd4_open: replay failed" | 193 | dprintk("nfsd4_open: replay failed" |
192 | " restoring previous filehandle\n"); | 194 | " restoring previous filehandle\n"); |
@@ -285,7 +287,7 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
285 | cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; | 287 | cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; |
286 | memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, | 288 | memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, |
287 | putfh->pf_fhlen); | 289 | putfh->pf_fhlen); |
288 | return fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 290 | return fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
289 | } | 291 | } |
290 | 292 | ||
291 | static __be32 | 293 | static __be32 |
@@ -363,7 +365,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
363 | 365 | ||
364 | fh_init(&resfh, NFS4_FHSIZE); | 366 | fh_init(&resfh, NFS4_FHSIZE); |
365 | 367 | ||
366 | status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, MAY_CREATE); | 368 | status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, |
369 | NFSD_MAY_CREATE); | ||
367 | if (status == nfserr_symlink) | 370 | if (status == nfserr_symlink) |
368 | status = nfserr_notdir; | 371 | status = nfserr_notdir; |
369 | if (status) | 372 | if (status) |
@@ -445,7 +448,7 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
445 | { | 448 | { |
446 | __be32 status; | 449 | __be32 status; |
447 | 450 | ||
448 | status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 451 | status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
449 | if (status) | 452 | if (status) |
450 | return status; | 453 | return status; |
451 | 454 | ||
@@ -730,7 +733,7 @@ _nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
730 | int count; | 733 | int count; |
731 | __be32 status; | 734 | __be32 status; |
732 | 735 | ||
733 | status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP); | 736 | status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); |
734 | if (status) | 737 | if (status) |
735 | return status; | 738 | return status; |
736 | 739 | ||
@@ -843,10 +846,13 @@ struct nfsd4_operation { | |||
843 | #define ALLOWED_WITHOUT_FH 1 | 846 | #define ALLOWED_WITHOUT_FH 1 |
844 | /* GETATTR and ops not listed as returning NFS4ERR_MOVED: */ | 847 | /* GETATTR and ops not listed as returning NFS4ERR_MOVED: */ |
845 | #define ALLOWED_ON_ABSENT_FS 2 | 848 | #define ALLOWED_ON_ABSENT_FS 2 |
849 | char *op_name; | ||
846 | }; | 850 | }; |
847 | 851 | ||
848 | static struct nfsd4_operation nfsd4_ops[]; | 852 | static struct nfsd4_operation nfsd4_ops[]; |
849 | 853 | ||
854 | static inline char *nfsd4_op_name(unsigned opnum); | ||
855 | |||
850 | /* | 856 | /* |
851 | * COMPOUND call. | 857 | * COMPOUND call. |
852 | */ | 858 | */ |
@@ -888,7 +894,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
888 | while (!status && resp->opcnt < args->opcnt) { | 894 | while (!status && resp->opcnt < args->opcnt) { |
889 | op = &args->ops[resp->opcnt++]; | 895 | op = &args->ops[resp->opcnt++]; |
890 | 896 | ||
891 | dprintk("nfsv4 compound op #%d: %d\n", resp->opcnt, op->opnum); | 897 | dprintk("nfsv4 compound op #%d/%d: %d (%s)\n", |
898 | resp->opcnt, args->opcnt, op->opnum, | ||
899 | nfsd4_op_name(op->opnum)); | ||
892 | 900 | ||
893 | /* | 901 | /* |
894 | * The XDR decode routines may have pre-set op->status; | 902 | * The XDR decode routines may have pre-set op->status; |
@@ -952,126 +960,170 @@ encode_op: | |||
952 | out: | 960 | out: |
953 | nfsd4_release_compoundargs(args); | 961 | nfsd4_release_compoundargs(args); |
954 | cstate_free(cstate); | 962 | cstate_free(cstate); |
963 | dprintk("nfsv4 compound returned %d\n", ntohl(status)); | ||
955 | return status; | 964 | return status; |
956 | } | 965 | } |
957 | 966 | ||
958 | static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = { | 967 | static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = { |
959 | [OP_ACCESS] = { | 968 | [OP_ACCESS] = { |
960 | .op_func = (nfsd4op_func)nfsd4_access, | 969 | .op_func = (nfsd4op_func)nfsd4_access, |
970 | .op_name = "OP_ACCESS", | ||
961 | }, | 971 | }, |
962 | [OP_CLOSE] = { | 972 | [OP_CLOSE] = { |
963 | .op_func = (nfsd4op_func)nfsd4_close, | 973 | .op_func = (nfsd4op_func)nfsd4_close, |
974 | .op_name = "OP_CLOSE", | ||
964 | }, | 975 | }, |
965 | [OP_COMMIT] = { | 976 | [OP_COMMIT] = { |
966 | .op_func = (nfsd4op_func)nfsd4_commit, | 977 | .op_func = (nfsd4op_func)nfsd4_commit, |
978 | .op_name = "OP_COMMIT", | ||
967 | }, | 979 | }, |
968 | [OP_CREATE] = { | 980 | [OP_CREATE] = { |
969 | .op_func = (nfsd4op_func)nfsd4_create, | 981 | .op_func = (nfsd4op_func)nfsd4_create, |
982 | .op_name = "OP_CREATE", | ||
970 | }, | 983 | }, |
971 | [OP_DELEGRETURN] = { | 984 | [OP_DELEGRETURN] = { |
972 | .op_func = (nfsd4op_func)nfsd4_delegreturn, | 985 | .op_func = (nfsd4op_func)nfsd4_delegreturn, |
986 | .op_name = "OP_DELEGRETURN", | ||
973 | }, | 987 | }, |
974 | [OP_GETATTR] = { | 988 | [OP_GETATTR] = { |
975 | .op_func = (nfsd4op_func)nfsd4_getattr, | 989 | .op_func = (nfsd4op_func)nfsd4_getattr, |
976 | .op_flags = ALLOWED_ON_ABSENT_FS, | 990 | .op_flags = ALLOWED_ON_ABSENT_FS, |
991 | .op_name = "OP_GETATTR", | ||
977 | }, | 992 | }, |
978 | [OP_GETFH] = { | 993 | [OP_GETFH] = { |
979 | .op_func = (nfsd4op_func)nfsd4_getfh, | 994 | .op_func = (nfsd4op_func)nfsd4_getfh, |
995 | .op_name = "OP_GETFH", | ||
980 | }, | 996 | }, |
981 | [OP_LINK] = { | 997 | [OP_LINK] = { |
982 | .op_func = (nfsd4op_func)nfsd4_link, | 998 | .op_func = (nfsd4op_func)nfsd4_link, |
999 | .op_name = "OP_LINK", | ||
983 | }, | 1000 | }, |
984 | [OP_LOCK] = { | 1001 | [OP_LOCK] = { |
985 | .op_func = (nfsd4op_func)nfsd4_lock, | 1002 | .op_func = (nfsd4op_func)nfsd4_lock, |
1003 | .op_name = "OP_LOCK", | ||
986 | }, | 1004 | }, |
987 | [OP_LOCKT] = { | 1005 | [OP_LOCKT] = { |
988 | .op_func = (nfsd4op_func)nfsd4_lockt, | 1006 | .op_func = (nfsd4op_func)nfsd4_lockt, |
1007 | .op_name = "OP_LOCKT", | ||
989 | }, | 1008 | }, |
990 | [OP_LOCKU] = { | 1009 | [OP_LOCKU] = { |
991 | .op_func = (nfsd4op_func)nfsd4_locku, | 1010 | .op_func = (nfsd4op_func)nfsd4_locku, |
1011 | .op_name = "OP_LOCKU", | ||
992 | }, | 1012 | }, |
993 | [OP_LOOKUP] = { | 1013 | [OP_LOOKUP] = { |
994 | .op_func = (nfsd4op_func)nfsd4_lookup, | 1014 | .op_func = (nfsd4op_func)nfsd4_lookup, |
1015 | .op_name = "OP_LOOKUP", | ||
995 | }, | 1016 | }, |
996 | [OP_LOOKUPP] = { | 1017 | [OP_LOOKUPP] = { |
997 | .op_func = (nfsd4op_func)nfsd4_lookupp, | 1018 | .op_func = (nfsd4op_func)nfsd4_lookupp, |
1019 | .op_name = "OP_LOOKUPP", | ||
998 | }, | 1020 | }, |
999 | [OP_NVERIFY] = { | 1021 | [OP_NVERIFY] = { |
1000 | .op_func = (nfsd4op_func)nfsd4_nverify, | 1022 | .op_func = (nfsd4op_func)nfsd4_nverify, |
1023 | .op_name = "OP_NVERIFY", | ||
1001 | }, | 1024 | }, |
1002 | [OP_OPEN] = { | 1025 | [OP_OPEN] = { |
1003 | .op_func = (nfsd4op_func)nfsd4_open, | 1026 | .op_func = (nfsd4op_func)nfsd4_open, |
1027 | .op_name = "OP_OPEN", | ||
1004 | }, | 1028 | }, |
1005 | [OP_OPEN_CONFIRM] = { | 1029 | [OP_OPEN_CONFIRM] = { |
1006 | .op_func = (nfsd4op_func)nfsd4_open_confirm, | 1030 | .op_func = (nfsd4op_func)nfsd4_open_confirm, |
1031 | .op_name = "OP_OPEN_CONFIRM", | ||
1007 | }, | 1032 | }, |
1008 | [OP_OPEN_DOWNGRADE] = { | 1033 | [OP_OPEN_DOWNGRADE] = { |
1009 | .op_func = (nfsd4op_func)nfsd4_open_downgrade, | 1034 | .op_func = (nfsd4op_func)nfsd4_open_downgrade, |
1035 | .op_name = "OP_OPEN_DOWNGRADE", | ||
1010 | }, | 1036 | }, |
1011 | [OP_PUTFH] = { | 1037 | [OP_PUTFH] = { |
1012 | .op_func = (nfsd4op_func)nfsd4_putfh, | 1038 | .op_func = (nfsd4op_func)nfsd4_putfh, |
1013 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1039 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1040 | .op_name = "OP_PUTFH", | ||
1014 | }, | 1041 | }, |
1015 | [OP_PUTPUBFH] = { | 1042 | [OP_PUTPUBFH] = { |
1016 | /* unsupported; just for future reference: */ | 1043 | /* unsupported, just for future reference: */ |
1017 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1044 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1045 | .op_name = "OP_PUTPUBFH", | ||
1018 | }, | 1046 | }, |
1019 | [OP_PUTROOTFH] = { | 1047 | [OP_PUTROOTFH] = { |
1020 | .op_func = (nfsd4op_func)nfsd4_putrootfh, | 1048 | .op_func = (nfsd4op_func)nfsd4_putrootfh, |
1021 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1049 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1050 | .op_name = "OP_PUTROOTFH", | ||
1022 | }, | 1051 | }, |
1023 | [OP_READ] = { | 1052 | [OP_READ] = { |
1024 | .op_func = (nfsd4op_func)nfsd4_read, | 1053 | .op_func = (nfsd4op_func)nfsd4_read, |
1054 | .op_name = "OP_READ", | ||
1025 | }, | 1055 | }, |
1026 | [OP_READDIR] = { | 1056 | [OP_READDIR] = { |
1027 | .op_func = (nfsd4op_func)nfsd4_readdir, | 1057 | .op_func = (nfsd4op_func)nfsd4_readdir, |
1058 | .op_name = "OP_READDIR", | ||
1028 | }, | 1059 | }, |
1029 | [OP_READLINK] = { | 1060 | [OP_READLINK] = { |
1030 | .op_func = (nfsd4op_func)nfsd4_readlink, | 1061 | .op_func = (nfsd4op_func)nfsd4_readlink, |
1062 | .op_name = "OP_READLINK", | ||
1031 | }, | 1063 | }, |
1032 | [OP_REMOVE] = { | 1064 | [OP_REMOVE] = { |
1033 | .op_func = (nfsd4op_func)nfsd4_remove, | 1065 | .op_func = (nfsd4op_func)nfsd4_remove, |
1066 | .op_name = "OP_REMOVE", | ||
1034 | }, | 1067 | }, |
1035 | [OP_RENAME] = { | 1068 | [OP_RENAME] = { |
1069 | .op_name = "OP_RENAME", | ||
1036 | .op_func = (nfsd4op_func)nfsd4_rename, | 1070 | .op_func = (nfsd4op_func)nfsd4_rename, |
1037 | }, | 1071 | }, |
1038 | [OP_RENEW] = { | 1072 | [OP_RENEW] = { |
1039 | .op_func = (nfsd4op_func)nfsd4_renew, | 1073 | .op_func = (nfsd4op_func)nfsd4_renew, |
1040 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1074 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1075 | .op_name = "OP_RENEW", | ||
1041 | }, | 1076 | }, |
1042 | [OP_RESTOREFH] = { | 1077 | [OP_RESTOREFH] = { |
1043 | .op_func = (nfsd4op_func)nfsd4_restorefh, | 1078 | .op_func = (nfsd4op_func)nfsd4_restorefh, |
1044 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1079 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1080 | .op_name = "OP_RESTOREFH", | ||
1045 | }, | 1081 | }, |
1046 | [OP_SAVEFH] = { | 1082 | [OP_SAVEFH] = { |
1047 | .op_func = (nfsd4op_func)nfsd4_savefh, | 1083 | .op_func = (nfsd4op_func)nfsd4_savefh, |
1084 | .op_name = "OP_SAVEFH", | ||
1048 | }, | 1085 | }, |
1049 | [OP_SECINFO] = { | 1086 | [OP_SECINFO] = { |
1050 | .op_func = (nfsd4op_func)nfsd4_secinfo, | 1087 | .op_func = (nfsd4op_func)nfsd4_secinfo, |
1088 | .op_name = "OP_SECINFO", | ||
1051 | }, | 1089 | }, |
1052 | [OP_SETATTR] = { | 1090 | [OP_SETATTR] = { |
1053 | .op_func = (nfsd4op_func)nfsd4_setattr, | 1091 | .op_func = (nfsd4op_func)nfsd4_setattr, |
1092 | .op_name = "OP_SETATTR", | ||
1054 | }, | 1093 | }, |
1055 | [OP_SETCLIENTID] = { | 1094 | [OP_SETCLIENTID] = { |
1056 | .op_func = (nfsd4op_func)nfsd4_setclientid, | 1095 | .op_func = (nfsd4op_func)nfsd4_setclientid, |
1057 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1096 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1097 | .op_name = "OP_SETCLIENTID", | ||
1058 | }, | 1098 | }, |
1059 | [OP_SETCLIENTID_CONFIRM] = { | 1099 | [OP_SETCLIENTID_CONFIRM] = { |
1060 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, | 1100 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, |
1061 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1101 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1102 | .op_name = "OP_SETCLIENTID_CONFIRM", | ||
1062 | }, | 1103 | }, |
1063 | [OP_VERIFY] = { | 1104 | [OP_VERIFY] = { |
1064 | .op_func = (nfsd4op_func)nfsd4_verify, | 1105 | .op_func = (nfsd4op_func)nfsd4_verify, |
1106 | .op_name = "OP_VERIFY", | ||
1065 | }, | 1107 | }, |
1066 | [OP_WRITE] = { | 1108 | [OP_WRITE] = { |
1067 | .op_func = (nfsd4op_func)nfsd4_write, | 1109 | .op_func = (nfsd4op_func)nfsd4_write, |
1110 | .op_name = "OP_WRITE", | ||
1068 | }, | 1111 | }, |
1069 | [OP_RELEASE_LOCKOWNER] = { | 1112 | [OP_RELEASE_LOCKOWNER] = { |
1070 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, | 1113 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, |
1071 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1114 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1115 | .op_name = "OP_RELEASE_LOCKOWNER", | ||
1072 | }, | 1116 | }, |
1073 | }; | 1117 | }; |
1074 | 1118 | ||
1119 | static inline char * | ||
1120 | nfsd4_op_name(unsigned opnum) | ||
1121 | { | ||
1122 | if (opnum < ARRAY_SIZE(nfsd4_ops)) | ||
1123 | return nfsd4_ops[opnum].op_name; | ||
1124 | return "unknown_operation"; | ||
1125 | } | ||
1126 | |||
1075 | #define nfs4svc_decode_voidargs NULL | 1127 | #define nfs4svc_decode_voidargs NULL |
1076 | #define nfs4svc_release_void NULL | 1128 | #define nfs4svc_release_void NULL |
1077 | #define nfsd4_voidres nfsd4_voidargs | 1129 | #define nfsd4_voidres nfsd4_voidargs |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8799b8708188..1578d7a2667e 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -1173,6 +1173,24 @@ static inline int deny_valid(u32 x) | |||
1173 | return x <= NFS4_SHARE_DENY_BOTH; | 1173 | return x <= NFS4_SHARE_DENY_BOTH; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | /* | ||
1177 | * We store the NONE, READ, WRITE, and BOTH bits separately in the | ||
1178 | * st_{access,deny}_bmap field of the stateid, in order to track not | ||
1179 | * only what share bits are currently in force, but also what | ||
1180 | * combinations of share bits previous opens have used. This allows us | ||
1181 | * to enforce the recommendation of rfc 3530 14.2.19 that the server | ||
1182 | * return an error if the client attempt to downgrade to a combination | ||
1183 | * of share bits not explicable by closing some of its previous opens. | ||
1184 | * | ||
1185 | * XXX: This enforcement is actually incomplete, since we don't keep | ||
1186 | * track of access/deny bit combinations; so, e.g., we allow: | ||
1187 | * | ||
1188 | * OPEN allow read, deny write | ||
1189 | * OPEN allow both, deny none | ||
1190 | * DOWNGRADE allow read, deny none | ||
1191 | * | ||
1192 | * which we should reject. | ||
1193 | */ | ||
1176 | static void | 1194 | static void |
1177 | set_access(unsigned int *access, unsigned long bmap) { | 1195 | set_access(unsigned int *access, unsigned long bmap) { |
1178 | int i; | 1196 | int i; |
@@ -1570,6 +1588,10 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_sta | |||
1570 | int err = get_write_access(inode); | 1588 | int err = get_write_access(inode); |
1571 | if (err) | 1589 | if (err) |
1572 | return nfserrno(err); | 1590 | return nfserrno(err); |
1591 | err = mnt_want_write(cur_fh->fh_export->ex_path.mnt); | ||
1592 | if (err) | ||
1593 | return nfserrno(err); | ||
1594 | file_take_write(filp); | ||
1573 | } | 1595 | } |
1574 | status = nfsd4_truncate(rqstp, cur_fh, open); | 1596 | status = nfsd4_truncate(rqstp, cur_fh, open); |
1575 | if (status) { | 1597 | if (status) { |
@@ -1579,8 +1601,8 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_sta | |||
1579 | } | 1601 | } |
1580 | /* remember the open */ | 1602 | /* remember the open */ |
1581 | filp->f_mode |= open->op_share_access; | 1603 | filp->f_mode |= open->op_share_access; |
1582 | set_bit(open->op_share_access, &stp->st_access_bmap); | 1604 | __set_bit(open->op_share_access, &stp->st_access_bmap); |
1583 | set_bit(open->op_share_deny, &stp->st_deny_bmap); | 1605 | __set_bit(open->op_share_deny, &stp->st_deny_bmap); |
1584 | 1606 | ||
1585 | return nfs_ok; | 1607 | return nfs_ok; |
1586 | } | 1608 | } |
@@ -1722,9 +1744,9 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf | |||
1722 | /* Stateid was not found, this is a new OPEN */ | 1744 | /* Stateid was not found, this is a new OPEN */ |
1723 | int flags = 0; | 1745 | int flags = 0; |
1724 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) | 1746 | if (open->op_share_access & NFS4_SHARE_ACCESS_READ) |
1725 | flags |= MAY_READ; | 1747 | flags |= NFSD_MAY_READ; |
1726 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) | 1748 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) |
1727 | flags |= MAY_WRITE; | 1749 | flags |= NFSD_MAY_WRITE; |
1728 | status = nfs4_new_open(rqstp, &stp, dp, current_fh, flags); | 1750 | status = nfs4_new_open(rqstp, &stp, dp, current_fh, flags); |
1729 | if (status) | 1751 | if (status) |
1730 | goto out; | 1752 | goto out; |
@@ -2610,7 +2632,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2610 | return nfserr_inval; | 2632 | return nfserr_inval; |
2611 | 2633 | ||
2612 | if ((status = fh_verify(rqstp, &cstate->current_fh, | 2634 | if ((status = fh_verify(rqstp, &cstate->current_fh, |
2613 | S_IFREG, MAY_LOCK))) { | 2635 | S_IFREG, NFSD_MAY_LOCK))) { |
2614 | dprintk("NFSD: nfsd4_lock: permission denied!\n"); | 2636 | dprintk("NFSD: nfsd4_lock: permission denied!\n"); |
2615 | return status; | 2637 | return status; |
2616 | } | 2638 | } |
@@ -3249,12 +3271,14 @@ nfs4_state_shutdown(void) | |||
3249 | nfs4_unlock_state(); | 3271 | nfs4_unlock_state(); |
3250 | } | 3272 | } |
3251 | 3273 | ||
3274 | /* | ||
3275 | * user_recovery_dirname is protected by the nfsd_mutex since it's only | ||
3276 | * accessed when nfsd is starting. | ||
3277 | */ | ||
3252 | static void | 3278 | static void |
3253 | nfs4_set_recdir(char *recdir) | 3279 | nfs4_set_recdir(char *recdir) |
3254 | { | 3280 | { |
3255 | nfs4_lock_state(); | ||
3256 | strcpy(user_recovery_dirname, recdir); | 3281 | strcpy(user_recovery_dirname, recdir); |
3257 | nfs4_unlock_state(); | ||
3258 | } | 3282 | } |
3259 | 3283 | ||
3260 | /* | 3284 | /* |
@@ -3278,6 +3302,12 @@ nfs4_reset_recoverydir(char *recdir) | |||
3278 | return status; | 3302 | return status; |
3279 | } | 3303 | } |
3280 | 3304 | ||
3305 | char * | ||
3306 | nfs4_recoverydir(void) | ||
3307 | { | ||
3308 | return user_recovery_dirname; | ||
3309 | } | ||
3310 | |||
3281 | /* | 3311 | /* |
3282 | * Called when leasetime is changed. | 3312 | * Called when leasetime is changed. |
3283 | * | 3313 | * |
@@ -3286,11 +3316,12 @@ nfs4_reset_recoverydir(char *recdir) | |||
3286 | * we start to register any changes in lease time. If the administrator | 3316 | * we start to register any changes in lease time. If the administrator |
3287 | * really wants to change the lease time *now*, they can go ahead and bring | 3317 | * really wants to change the lease time *now*, they can go ahead and bring |
3288 | * nfsd down and then back up again after changing the lease time. | 3318 | * nfsd down and then back up again after changing the lease time. |
3319 | * | ||
3320 | * user_lease_time is protected by nfsd_mutex since it's only really accessed | ||
3321 | * when nfsd is starting | ||
3289 | */ | 3322 | */ |
3290 | void | 3323 | void |
3291 | nfs4_reset_lease(time_t leasetime) | 3324 | nfs4_reset_lease(time_t leasetime) |
3292 | { | 3325 | { |
3293 | lock_kernel(); | ||
3294 | user_lease_time = leasetime; | 3326 | user_lease_time = leasetime; |
3295 | unlock_kernel(); | ||
3296 | } | 3327 | } |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index c513bbdf2d36..14ba4d9b2859 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -986,10 +986,74 @@ nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_rel | |||
986 | } | 986 | } |
987 | 987 | ||
988 | static __be32 | 988 | static __be32 |
989 | nfsd4_decode_noop(struct nfsd4_compoundargs *argp, void *p) | ||
990 | { | ||
991 | return nfs_ok; | ||
992 | } | ||
993 | |||
994 | static __be32 | ||
995 | nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p) | ||
996 | { | ||
997 | return nfserr_opnotsupp; | ||
998 | } | ||
999 | |||
1000 | typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *); | ||
1001 | |||
1002 | static nfsd4_dec nfsd4_dec_ops[] = { | ||
1003 | [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access, | ||
1004 | [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close, | ||
1005 | [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit, | ||
1006 | [OP_CREATE] = (nfsd4_dec)nfsd4_decode_create, | ||
1007 | [OP_DELEGPURGE] = (nfsd4_dec)nfsd4_decode_notsupp, | ||
1008 | [OP_DELEGRETURN] = (nfsd4_dec)nfsd4_decode_delegreturn, | ||
1009 | [OP_GETATTR] = (nfsd4_dec)nfsd4_decode_getattr, | ||
1010 | [OP_GETFH] = (nfsd4_dec)nfsd4_decode_noop, | ||
1011 | [OP_LINK] = (nfsd4_dec)nfsd4_decode_link, | ||
1012 | [OP_LOCK] = (nfsd4_dec)nfsd4_decode_lock, | ||
1013 | [OP_LOCKT] = (nfsd4_dec)nfsd4_decode_lockt, | ||
1014 | [OP_LOCKU] = (nfsd4_dec)nfsd4_decode_locku, | ||
1015 | [OP_LOOKUP] = (nfsd4_dec)nfsd4_decode_lookup, | ||
1016 | [OP_LOOKUPP] = (nfsd4_dec)nfsd4_decode_noop, | ||
1017 | [OP_NVERIFY] = (nfsd4_dec)nfsd4_decode_verify, | ||
1018 | [OP_OPEN] = (nfsd4_dec)nfsd4_decode_open, | ||
1019 | [OP_OPENATTR] = (nfsd4_dec)nfsd4_decode_notsupp, | ||
1020 | [OP_OPEN_CONFIRM] = (nfsd4_dec)nfsd4_decode_open_confirm, | ||
1021 | [OP_OPEN_DOWNGRADE] = (nfsd4_dec)nfsd4_decode_open_downgrade, | ||
1022 | [OP_PUTFH] = (nfsd4_dec)nfsd4_decode_putfh, | ||
1023 | [OP_PUTPUBFH] = (nfsd4_dec)nfsd4_decode_notsupp, | ||
1024 | [OP_PUTROOTFH] = (nfsd4_dec)nfsd4_decode_noop, | ||
1025 | [OP_READ] = (nfsd4_dec)nfsd4_decode_read, | ||
1026 | [OP_READDIR] = (nfsd4_dec)nfsd4_decode_readdir, | ||
1027 | [OP_READLINK] = (nfsd4_dec)nfsd4_decode_noop, | ||
1028 | [OP_REMOVE] = (nfsd4_dec)nfsd4_decode_remove, | ||
1029 | [OP_RENAME] = (nfsd4_dec)nfsd4_decode_rename, | ||
1030 | [OP_RENEW] = (nfsd4_dec)nfsd4_decode_renew, | ||
1031 | [OP_RESTOREFH] = (nfsd4_dec)nfsd4_decode_noop, | ||
1032 | [OP_SAVEFH] = (nfsd4_dec)nfsd4_decode_noop, | ||
1033 | [OP_SECINFO] = (nfsd4_dec)nfsd4_decode_secinfo, | ||
1034 | [OP_SETATTR] = (nfsd4_dec)nfsd4_decode_setattr, | ||
1035 | [OP_SETCLIENTID] = (nfsd4_dec)nfsd4_decode_setclientid, | ||
1036 | [OP_SETCLIENTID_CONFIRM] = (nfsd4_dec)nfsd4_decode_setclientid_confirm, | ||
1037 | [OP_VERIFY] = (nfsd4_dec)nfsd4_decode_verify, | ||
1038 | [OP_WRITE] = (nfsd4_dec)nfsd4_decode_write, | ||
1039 | [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner, | ||
1040 | }; | ||
1041 | |||
1042 | struct nfsd4_minorversion_ops { | ||
1043 | nfsd4_dec *decoders; | ||
1044 | int nops; | ||
1045 | }; | ||
1046 | |||
1047 | static struct nfsd4_minorversion_ops nfsd4_minorversion[] = { | ||
1048 | [0] = { nfsd4_dec_ops, ARRAY_SIZE(nfsd4_dec_ops) }, | ||
1049 | }; | ||
1050 | |||
1051 | static __be32 | ||
989 | nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | 1052 | nfsd4_decode_compound(struct nfsd4_compoundargs *argp) |
990 | { | 1053 | { |
991 | DECODE_HEAD; | 1054 | DECODE_HEAD; |
992 | struct nfsd4_op *op; | 1055 | struct nfsd4_op *op; |
1056 | struct nfsd4_minorversion_ops *ops; | ||
993 | int i; | 1057 | int i; |
994 | 1058 | ||
995 | /* | 1059 | /* |
@@ -1019,6 +1083,10 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1019 | } | 1083 | } |
1020 | } | 1084 | } |
1021 | 1085 | ||
1086 | if (argp->minorversion >= ARRAY_SIZE(nfsd4_minorversion)) | ||
1087 | argp->opcnt = 0; | ||
1088 | |||
1089 | ops = &nfsd4_minorversion[argp->minorversion]; | ||
1022 | for (i = 0; i < argp->opcnt; i++) { | 1090 | for (i = 0; i < argp->opcnt; i++) { |
1023 | op = &argp->ops[i]; | 1091 | op = &argp->ops[i]; |
1024 | op->replay = NULL; | 1092 | op->replay = NULL; |
@@ -1056,120 +1124,11 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1056 | } | 1124 | } |
1057 | op->opnum = ntohl(*argp->p++); | 1125 | op->opnum = ntohl(*argp->p++); |
1058 | 1126 | ||
1059 | switch (op->opnum) { | 1127 | if (op->opnum >= OP_ACCESS && op->opnum < ops->nops) |
1060 | case 2: /* Reserved operation */ | 1128 | op->status = ops->decoders[op->opnum](argp, &op->u); |
1061 | op->opnum = OP_ILLEGAL; | 1129 | else { |
1062 | if (argp->minorversion == 0) | ||
1063 | op->status = nfserr_op_illegal; | ||
1064 | else | ||
1065 | op->status = nfserr_minor_vers_mismatch; | ||
1066 | break; | ||
1067 | case OP_ACCESS: | ||
1068 | op->status = nfsd4_decode_access(argp, &op->u.access); | ||
1069 | break; | ||
1070 | case OP_CLOSE: | ||
1071 | op->status = nfsd4_decode_close(argp, &op->u.close); | ||
1072 | break; | ||
1073 | case OP_COMMIT: | ||
1074 | op->status = nfsd4_decode_commit(argp, &op->u.commit); | ||
1075 | break; | ||
1076 | case OP_CREATE: | ||
1077 | op->status = nfsd4_decode_create(argp, &op->u.create); | ||
1078 | break; | ||
1079 | case OP_DELEGRETURN: | ||
1080 | op->status = nfsd4_decode_delegreturn(argp, &op->u.delegreturn); | ||
1081 | break; | ||
1082 | case OP_GETATTR: | ||
1083 | op->status = nfsd4_decode_getattr(argp, &op->u.getattr); | ||
1084 | break; | ||
1085 | case OP_GETFH: | ||
1086 | op->status = nfs_ok; | ||
1087 | break; | ||
1088 | case OP_LINK: | ||
1089 | op->status = nfsd4_decode_link(argp, &op->u.link); | ||
1090 | break; | ||
1091 | case OP_LOCK: | ||
1092 | op->status = nfsd4_decode_lock(argp, &op->u.lock); | ||
1093 | break; | ||
1094 | case OP_LOCKT: | ||
1095 | op->status = nfsd4_decode_lockt(argp, &op->u.lockt); | ||
1096 | break; | ||
1097 | case OP_LOCKU: | ||
1098 | op->status = nfsd4_decode_locku(argp, &op->u.locku); | ||
1099 | break; | ||
1100 | case OP_LOOKUP: | ||
1101 | op->status = nfsd4_decode_lookup(argp, &op->u.lookup); | ||
1102 | break; | ||
1103 | case OP_LOOKUPP: | ||
1104 | op->status = nfs_ok; | ||
1105 | break; | ||
1106 | case OP_NVERIFY: | ||
1107 | op->status = nfsd4_decode_verify(argp, &op->u.nverify); | ||
1108 | break; | ||
1109 | case OP_OPEN: | ||
1110 | op->status = nfsd4_decode_open(argp, &op->u.open); | ||
1111 | break; | ||
1112 | case OP_OPEN_CONFIRM: | ||
1113 | op->status = nfsd4_decode_open_confirm(argp, &op->u.open_confirm); | ||
1114 | break; | ||
1115 | case OP_OPEN_DOWNGRADE: | ||
1116 | op->status = nfsd4_decode_open_downgrade(argp, &op->u.open_downgrade); | ||
1117 | break; | ||
1118 | case OP_PUTFH: | ||
1119 | op->status = nfsd4_decode_putfh(argp, &op->u.putfh); | ||
1120 | break; | ||
1121 | case OP_PUTROOTFH: | ||
1122 | op->status = nfs_ok; | ||
1123 | break; | ||
1124 | case OP_READ: | ||
1125 | op->status = nfsd4_decode_read(argp, &op->u.read); | ||
1126 | break; | ||
1127 | case OP_READDIR: | ||
1128 | op->status = nfsd4_decode_readdir(argp, &op->u.readdir); | ||
1129 | break; | ||
1130 | case OP_READLINK: | ||
1131 | op->status = nfs_ok; | ||
1132 | break; | ||
1133 | case OP_REMOVE: | ||
1134 | op->status = nfsd4_decode_remove(argp, &op->u.remove); | ||
1135 | break; | ||
1136 | case OP_RENAME: | ||
1137 | op->status = nfsd4_decode_rename(argp, &op->u.rename); | ||
1138 | break; | ||
1139 | case OP_RESTOREFH: | ||
1140 | op->status = nfs_ok; | ||
1141 | break; | ||
1142 | case OP_RENEW: | ||
1143 | op->status = nfsd4_decode_renew(argp, &op->u.renew); | ||
1144 | break; | ||
1145 | case OP_SAVEFH: | ||
1146 | op->status = nfs_ok; | ||
1147 | break; | ||
1148 | case OP_SECINFO: | ||
1149 | op->status = nfsd4_decode_secinfo(argp, &op->u.secinfo); | ||
1150 | break; | ||
1151 | case OP_SETATTR: | ||
1152 | op->status = nfsd4_decode_setattr(argp, &op->u.setattr); | ||
1153 | break; | ||
1154 | case OP_SETCLIENTID: | ||
1155 | op->status = nfsd4_decode_setclientid(argp, &op->u.setclientid); | ||
1156 | break; | ||
1157 | case OP_SETCLIENTID_CONFIRM: | ||
1158 | op->status = nfsd4_decode_setclientid_confirm(argp, &op->u.setclientid_confirm); | ||
1159 | break; | ||
1160 | case OP_VERIFY: | ||
1161 | op->status = nfsd4_decode_verify(argp, &op->u.verify); | ||
1162 | break; | ||
1163 | case OP_WRITE: | ||
1164 | op->status = nfsd4_decode_write(argp, &op->u.write); | ||
1165 | break; | ||
1166 | case OP_RELEASE_LOCKOWNER: | ||
1167 | op->status = nfsd4_decode_release_lockowner(argp, &op->u.release_lockowner); | ||
1168 | break; | ||
1169 | default: | ||
1170 | op->opnum = OP_ILLEGAL; | 1130 | op->opnum = OP_ILLEGAL; |
1171 | op->status = nfserr_op_illegal; | 1131 | op->status = nfserr_op_illegal; |
1172 | break; | ||
1173 | } | 1132 | } |
1174 | 1133 | ||
1175 | if (op->status) { | 1134 | if (op->status) { |
@@ -1201,11 +1160,11 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1201 | *p++ = htonl((u32)((n) >> 32)); \ | 1160 | *p++ = htonl((u32)((n) >> 32)); \ |
1202 | *p++ = htonl((u32)(n)); \ | 1161 | *p++ = htonl((u32)(n)); \ |
1203 | } while (0) | 1162 | } while (0) |
1204 | #define WRITEMEM(ptr,nbytes) do { \ | 1163 | #define WRITEMEM(ptr,nbytes) do { if (nbytes > 0) { \ |
1205 | *(p + XDR_QUADLEN(nbytes) -1) = 0; \ | 1164 | *(p + XDR_QUADLEN(nbytes) -1) = 0; \ |
1206 | memcpy(p, ptr, nbytes); \ | 1165 | memcpy(p, ptr, nbytes); \ |
1207 | p += XDR_QUADLEN(nbytes); \ | 1166 | p += XDR_QUADLEN(nbytes); \ |
1208 | } while (0) | 1167 | }} while (0) |
1209 | #define WRITECINFO(c) do { \ | 1168 | #define WRITECINFO(c) do { \ |
1210 | *p++ = htonl(c.atomic); \ | 1169 | *p++ = htonl(c.atomic); \ |
1211 | *p++ = htonl(c.before_ctime_sec); \ | 1170 | *p++ = htonl(c.before_ctime_sec); \ |
@@ -1991,7 +1950,7 @@ fail: | |||
1991 | return -EINVAL; | 1950 | return -EINVAL; |
1992 | } | 1951 | } |
1993 | 1952 | ||
1994 | static void | 1953 | static __be32 |
1995 | nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_access *access) | 1954 | nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_access *access) |
1996 | { | 1955 | { |
1997 | ENCODE_HEAD; | 1956 | ENCODE_HEAD; |
@@ -2002,9 +1961,10 @@ nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
2002 | WRITE32(access->ac_resp_access); | 1961 | WRITE32(access->ac_resp_access); |
2003 | ADJUST_ARGS(); | 1962 | ADJUST_ARGS(); |
2004 | } | 1963 | } |
1964 | return nfserr; | ||
2005 | } | 1965 | } |
2006 | 1966 | ||
2007 | static void | 1967 | static __be32 |
2008 | nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_close *close) | 1968 | nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_close *close) |
2009 | { | 1969 | { |
2010 | ENCODE_SEQID_OP_HEAD; | 1970 | ENCODE_SEQID_OP_HEAD; |
@@ -2016,10 +1976,11 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c | |||
2016 | ADJUST_ARGS(); | 1976 | ADJUST_ARGS(); |
2017 | } | 1977 | } |
2018 | ENCODE_SEQID_OP_TAIL(close->cl_stateowner); | 1978 | ENCODE_SEQID_OP_TAIL(close->cl_stateowner); |
1979 | return nfserr; | ||
2019 | } | 1980 | } |
2020 | 1981 | ||
2021 | 1982 | ||
2022 | static void | 1983 | static __be32 |
2023 | nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_commit *commit) | 1984 | nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_commit *commit) |
2024 | { | 1985 | { |
2025 | ENCODE_HEAD; | 1986 | ENCODE_HEAD; |
@@ -2029,9 +1990,10 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
2029 | WRITEMEM(commit->co_verf.data, 8); | 1990 | WRITEMEM(commit->co_verf.data, 8); |
2030 | ADJUST_ARGS(); | 1991 | ADJUST_ARGS(); |
2031 | } | 1992 | } |
1993 | return nfserr; | ||
2032 | } | 1994 | } |
2033 | 1995 | ||
2034 | static void | 1996 | static __be32 |
2035 | nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_create *create) | 1997 | nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_create *create) |
2036 | { | 1998 | { |
2037 | ENCODE_HEAD; | 1999 | ENCODE_HEAD; |
@@ -2044,6 +2006,7 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
2044 | WRITE32(create->cr_bmval[1]); | 2006 | WRITE32(create->cr_bmval[1]); |
2045 | ADJUST_ARGS(); | 2007 | ADJUST_ARGS(); |
2046 | } | 2008 | } |
2009 | return nfserr; | ||
2047 | } | 2010 | } |
2048 | 2011 | ||
2049 | static __be32 | 2012 | static __be32 |
@@ -2064,9 +2027,10 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
2064 | return nfserr; | 2027 | return nfserr; |
2065 | } | 2028 | } |
2066 | 2029 | ||
2067 | static void | 2030 | static __be32 |
2068 | nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh *fhp) | 2031 | nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh **fhpp) |
2069 | { | 2032 | { |
2033 | struct svc_fh *fhp = *fhpp; | ||
2070 | unsigned int len; | 2034 | unsigned int len; |
2071 | ENCODE_HEAD; | 2035 | ENCODE_HEAD; |
2072 | 2036 | ||
@@ -2077,6 +2041,7 @@ nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh | |||
2077 | WRITEMEM(&fhp->fh_handle.fh_base, len); | 2041 | WRITEMEM(&fhp->fh_handle.fh_base, len); |
2078 | ADJUST_ARGS(); | 2042 | ADJUST_ARGS(); |
2079 | } | 2043 | } |
2044 | return nfserr; | ||
2080 | } | 2045 | } |
2081 | 2046 | ||
2082 | /* | 2047 | /* |
@@ -2104,7 +2069,7 @@ nfsd4_encode_lock_denied(struct nfsd4_compoundres *resp, struct nfsd4_lock_denie | |||
2104 | ADJUST_ARGS(); | 2069 | ADJUST_ARGS(); |
2105 | } | 2070 | } |
2106 | 2071 | ||
2107 | static void | 2072 | static __be32 |
2108 | nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lock *lock) | 2073 | nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lock *lock) |
2109 | { | 2074 | { |
2110 | ENCODE_SEQID_OP_HEAD; | 2075 | ENCODE_SEQID_OP_HEAD; |
@@ -2118,16 +2083,18 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo | |||
2118 | nfsd4_encode_lock_denied(resp, &lock->lk_denied); | 2083 | nfsd4_encode_lock_denied(resp, &lock->lk_denied); |
2119 | 2084 | ||
2120 | ENCODE_SEQID_OP_TAIL(lock->lk_replay_owner); | 2085 | ENCODE_SEQID_OP_TAIL(lock->lk_replay_owner); |
2086 | return nfserr; | ||
2121 | } | 2087 | } |
2122 | 2088 | ||
2123 | static void | 2089 | static __be32 |
2124 | nfsd4_encode_lockt(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lockt *lockt) | 2090 | nfsd4_encode_lockt(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lockt *lockt) |
2125 | { | 2091 | { |
2126 | if (nfserr == nfserr_denied) | 2092 | if (nfserr == nfserr_denied) |
2127 | nfsd4_encode_lock_denied(resp, &lockt->lt_denied); | 2093 | nfsd4_encode_lock_denied(resp, &lockt->lt_denied); |
2094 | return nfserr; | ||
2128 | } | 2095 | } |
2129 | 2096 | ||
2130 | static void | 2097 | static __be32 |
2131 | nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_locku *locku) | 2098 | nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_locku *locku) |
2132 | { | 2099 | { |
2133 | ENCODE_SEQID_OP_HEAD; | 2100 | ENCODE_SEQID_OP_HEAD; |
@@ -2140,10 +2107,11 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l | |||
2140 | } | 2107 | } |
2141 | 2108 | ||
2142 | ENCODE_SEQID_OP_TAIL(locku->lu_stateowner); | 2109 | ENCODE_SEQID_OP_TAIL(locku->lu_stateowner); |
2110 | return nfserr; | ||
2143 | } | 2111 | } |
2144 | 2112 | ||
2145 | 2113 | ||
2146 | static void | 2114 | static __be32 |
2147 | nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_link *link) | 2115 | nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_link *link) |
2148 | { | 2116 | { |
2149 | ENCODE_HEAD; | 2117 | ENCODE_HEAD; |
@@ -2153,10 +2121,11 @@ nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_li | |||
2153 | WRITECINFO(link->li_cinfo); | 2121 | WRITECINFO(link->li_cinfo); |
2154 | ADJUST_ARGS(); | 2122 | ADJUST_ARGS(); |
2155 | } | 2123 | } |
2124 | return nfserr; | ||
2156 | } | 2125 | } |
2157 | 2126 | ||
2158 | 2127 | ||
2159 | static void | 2128 | static __be32 |
2160 | nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open *open) | 2129 | nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open *open) |
2161 | { | 2130 | { |
2162 | ENCODE_SEQID_OP_HEAD; | 2131 | ENCODE_SEQID_OP_HEAD; |
@@ -2219,9 +2188,10 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op | |||
2219 | /* XXX save filehandle here */ | 2188 | /* XXX save filehandle here */ |
2220 | out: | 2189 | out: |
2221 | ENCODE_SEQID_OP_TAIL(open->op_stateowner); | 2190 | ENCODE_SEQID_OP_TAIL(open->op_stateowner); |
2191 | return nfserr; | ||
2222 | } | 2192 | } |
2223 | 2193 | ||
2224 | static void | 2194 | static __be32 |
2225 | nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_confirm *oc) | 2195 | nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_confirm *oc) |
2226 | { | 2196 | { |
2227 | ENCODE_SEQID_OP_HEAD; | 2197 | ENCODE_SEQID_OP_HEAD; |
@@ -2234,9 +2204,10 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct | |||
2234 | } | 2204 | } |
2235 | 2205 | ||
2236 | ENCODE_SEQID_OP_TAIL(oc->oc_stateowner); | 2206 | ENCODE_SEQID_OP_TAIL(oc->oc_stateowner); |
2207 | return nfserr; | ||
2237 | } | 2208 | } |
2238 | 2209 | ||
2239 | static void | 2210 | static __be32 |
2240 | nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_downgrade *od) | 2211 | nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_open_downgrade *od) |
2241 | { | 2212 | { |
2242 | ENCODE_SEQID_OP_HEAD; | 2213 | ENCODE_SEQID_OP_HEAD; |
@@ -2249,6 +2220,7 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struc | |||
2249 | } | 2220 | } |
2250 | 2221 | ||
2251 | ENCODE_SEQID_OP_TAIL(od->od_stateowner); | 2222 | ENCODE_SEQID_OP_TAIL(od->od_stateowner); |
2223 | return nfserr; | ||
2252 | } | 2224 | } |
2253 | 2225 | ||
2254 | static __be32 | 2226 | static __be32 |
@@ -2443,7 +2415,7 @@ err_no_verf: | |||
2443 | return nfserr; | 2415 | return nfserr; |
2444 | } | 2416 | } |
2445 | 2417 | ||
2446 | static void | 2418 | static __be32 |
2447 | nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_remove *remove) | 2419 | nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_remove *remove) |
2448 | { | 2420 | { |
2449 | ENCODE_HEAD; | 2421 | ENCODE_HEAD; |
@@ -2453,9 +2425,10 @@ nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
2453 | WRITECINFO(remove->rm_cinfo); | 2425 | WRITECINFO(remove->rm_cinfo); |
2454 | ADJUST_ARGS(); | 2426 | ADJUST_ARGS(); |
2455 | } | 2427 | } |
2428 | return nfserr; | ||
2456 | } | 2429 | } |
2457 | 2430 | ||
2458 | static void | 2431 | static __be32 |
2459 | nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_rename *rename) | 2432 | nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_rename *rename) |
2460 | { | 2433 | { |
2461 | ENCODE_HEAD; | 2434 | ENCODE_HEAD; |
@@ -2466,9 +2439,10 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
2466 | WRITECINFO(rename->rn_tinfo); | 2439 | WRITECINFO(rename->rn_tinfo); |
2467 | ADJUST_ARGS(); | 2440 | ADJUST_ARGS(); |
2468 | } | 2441 | } |
2442 | return nfserr; | ||
2469 | } | 2443 | } |
2470 | 2444 | ||
2471 | static void | 2445 | static __be32 |
2472 | nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, | 2446 | nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, |
2473 | struct nfsd4_secinfo *secinfo) | 2447 | struct nfsd4_secinfo *secinfo) |
2474 | { | 2448 | { |
@@ -2532,13 +2506,14 @@ nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
2532 | out: | 2506 | out: |
2533 | if (exp) | 2507 | if (exp) |
2534 | exp_put(exp); | 2508 | exp_put(exp); |
2509 | return nfserr; | ||
2535 | } | 2510 | } |
2536 | 2511 | ||
2537 | /* | 2512 | /* |
2538 | * The SETATTR encode routine is special -- it always encodes a bitmap, | 2513 | * The SETATTR encode routine is special -- it always encodes a bitmap, |
2539 | * regardless of the error status. | 2514 | * regardless of the error status. |
2540 | */ | 2515 | */ |
2541 | static void | 2516 | static __be32 |
2542 | nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setattr *setattr) | 2517 | nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setattr *setattr) |
2543 | { | 2518 | { |
2544 | ENCODE_HEAD; | 2519 | ENCODE_HEAD; |
@@ -2555,9 +2530,10 @@ nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
2555 | WRITE32(setattr->sa_bmval[1]); | 2530 | WRITE32(setattr->sa_bmval[1]); |
2556 | } | 2531 | } |
2557 | ADJUST_ARGS(); | 2532 | ADJUST_ARGS(); |
2533 | return nfserr; | ||
2558 | } | 2534 | } |
2559 | 2535 | ||
2560 | static void | 2536 | static __be32 |
2561 | nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setclientid *scd) | 2537 | nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_setclientid *scd) |
2562 | { | 2538 | { |
2563 | ENCODE_HEAD; | 2539 | ENCODE_HEAD; |
@@ -2574,9 +2550,10 @@ nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct n | |||
2574 | WRITE32(0); | 2550 | WRITE32(0); |
2575 | ADJUST_ARGS(); | 2551 | ADJUST_ARGS(); |
2576 | } | 2552 | } |
2553 | return nfserr; | ||
2577 | } | 2554 | } |
2578 | 2555 | ||
2579 | static void | 2556 | static __be32 |
2580 | nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_write *write) | 2557 | nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_write *write) |
2581 | { | 2558 | { |
2582 | ENCODE_HEAD; | 2559 | ENCODE_HEAD; |
@@ -2588,8 +2565,56 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w | |||
2588 | WRITEMEM(write->wr_verifier.data, 8); | 2565 | WRITEMEM(write->wr_verifier.data, 8); |
2589 | ADJUST_ARGS(); | 2566 | ADJUST_ARGS(); |
2590 | } | 2567 | } |
2568 | return nfserr; | ||
2591 | } | 2569 | } |
2592 | 2570 | ||
2571 | static __be32 | ||
2572 | nfsd4_encode_noop(struct nfsd4_compoundres *resp, __be32 nfserr, void *p) | ||
2573 | { | ||
2574 | return nfserr; | ||
2575 | } | ||
2576 | |||
2577 | typedef __be32(* nfsd4_enc)(struct nfsd4_compoundres *, __be32, void *); | ||
2578 | |||
2579 | static nfsd4_enc nfsd4_enc_ops[] = { | ||
2580 | [OP_ACCESS] = (nfsd4_enc)nfsd4_encode_access, | ||
2581 | [OP_CLOSE] = (nfsd4_enc)nfsd4_encode_close, | ||
2582 | [OP_COMMIT] = (nfsd4_enc)nfsd4_encode_commit, | ||
2583 | [OP_CREATE] = (nfsd4_enc)nfsd4_encode_create, | ||
2584 | [OP_DELEGPURGE] = (nfsd4_enc)nfsd4_encode_noop, | ||
2585 | [OP_DELEGRETURN] = (nfsd4_enc)nfsd4_encode_noop, | ||
2586 | [OP_GETATTR] = (nfsd4_enc)nfsd4_encode_getattr, | ||
2587 | [OP_GETFH] = (nfsd4_enc)nfsd4_encode_getfh, | ||
2588 | [OP_LINK] = (nfsd4_enc)nfsd4_encode_link, | ||
2589 | [OP_LOCK] = (nfsd4_enc)nfsd4_encode_lock, | ||
2590 | [OP_LOCKT] = (nfsd4_enc)nfsd4_encode_lockt, | ||
2591 | [OP_LOCKU] = (nfsd4_enc)nfsd4_encode_locku, | ||
2592 | [OP_LOOKUP] = (nfsd4_enc)nfsd4_encode_noop, | ||
2593 | [OP_LOOKUPP] = (nfsd4_enc)nfsd4_encode_noop, | ||
2594 | [OP_NVERIFY] = (nfsd4_enc)nfsd4_encode_noop, | ||
2595 | [OP_OPEN] = (nfsd4_enc)nfsd4_encode_open, | ||
2596 | [OP_OPEN_CONFIRM] = (nfsd4_enc)nfsd4_encode_open_confirm, | ||
2597 | [OP_OPEN_DOWNGRADE] = (nfsd4_enc)nfsd4_encode_open_downgrade, | ||
2598 | [OP_PUTFH] = (nfsd4_enc)nfsd4_encode_noop, | ||
2599 | [OP_PUTPUBFH] = (nfsd4_enc)nfsd4_encode_noop, | ||
2600 | [OP_PUTROOTFH] = (nfsd4_enc)nfsd4_encode_noop, | ||
2601 | [OP_READ] = (nfsd4_enc)nfsd4_encode_read, | ||
2602 | [OP_READDIR] = (nfsd4_enc)nfsd4_encode_readdir, | ||
2603 | [OP_READLINK] = (nfsd4_enc)nfsd4_encode_readlink, | ||
2604 | [OP_REMOVE] = (nfsd4_enc)nfsd4_encode_remove, | ||
2605 | [OP_RENAME] = (nfsd4_enc)nfsd4_encode_rename, | ||
2606 | [OP_RENEW] = (nfsd4_enc)nfsd4_encode_noop, | ||
2607 | [OP_RESTOREFH] = (nfsd4_enc)nfsd4_encode_noop, | ||
2608 | [OP_SAVEFH] = (nfsd4_enc)nfsd4_encode_noop, | ||
2609 | [OP_SECINFO] = (nfsd4_enc)nfsd4_encode_secinfo, | ||
2610 | [OP_SETATTR] = (nfsd4_enc)nfsd4_encode_setattr, | ||
2611 | [OP_SETCLIENTID] = (nfsd4_enc)nfsd4_encode_setclientid, | ||
2612 | [OP_SETCLIENTID_CONFIRM] = (nfsd4_enc)nfsd4_encode_noop, | ||
2613 | [OP_VERIFY] = (nfsd4_enc)nfsd4_encode_noop, | ||
2614 | [OP_WRITE] = (nfsd4_enc)nfsd4_encode_write, | ||
2615 | [OP_RELEASE_LOCKOWNER] = (nfsd4_enc)nfsd4_encode_noop, | ||
2616 | }; | ||
2617 | |||
2593 | void | 2618 | void |
2594 | nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) | 2619 | nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) |
2595 | { | 2620 | { |
@@ -2601,101 +2626,12 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) | |||
2601 | statp = p++; /* to be backfilled at the end */ | 2626 | statp = p++; /* to be backfilled at the end */ |
2602 | ADJUST_ARGS(); | 2627 | ADJUST_ARGS(); |
2603 | 2628 | ||
2604 | switch (op->opnum) { | 2629 | if (op->opnum == OP_ILLEGAL) |
2605 | case OP_ACCESS: | 2630 | goto status; |
2606 | nfsd4_encode_access(resp, op->status, &op->u.access); | 2631 | BUG_ON(op->opnum < 0 || op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) || |
2607 | break; | 2632 | !nfsd4_enc_ops[op->opnum]); |
2608 | case OP_CLOSE: | 2633 | op->status = nfsd4_enc_ops[op->opnum](resp, op->status, &op->u); |
2609 | nfsd4_encode_close(resp, op->status, &op->u.close); | 2634 | status: |
2610 | break; | ||
2611 | case OP_COMMIT: | ||
2612 | nfsd4_encode_commit(resp, op->status, &op->u.commit); | ||
2613 | break; | ||
2614 | case OP_CREATE: | ||
2615 | nfsd4_encode_create(resp, op->status, &op->u.create); | ||
2616 | break; | ||
2617 | case OP_DELEGRETURN: | ||
2618 | break; | ||
2619 | case OP_GETATTR: | ||
2620 | op->status = nfsd4_encode_getattr(resp, op->status, &op->u.getattr); | ||
2621 | break; | ||
2622 | case OP_GETFH: | ||
2623 | nfsd4_encode_getfh(resp, op->status, op->u.getfh); | ||
2624 | break; | ||
2625 | case OP_LINK: | ||
2626 | nfsd4_encode_link(resp, op->status, &op->u.link); | ||
2627 | break; | ||
2628 | case OP_LOCK: | ||
2629 | nfsd4_encode_lock(resp, op->status, &op->u.lock); | ||
2630 | break; | ||
2631 | case OP_LOCKT: | ||
2632 | nfsd4_encode_lockt(resp, op->status, &op->u.lockt); | ||
2633 | break; | ||
2634 | case OP_LOCKU: | ||
2635 | nfsd4_encode_locku(resp, op->status, &op->u.locku); | ||
2636 | break; | ||
2637 | case OP_LOOKUP: | ||
2638 | break; | ||
2639 | case OP_LOOKUPP: | ||
2640 | break; | ||
2641 | case OP_NVERIFY: | ||
2642 | break; | ||
2643 | case OP_OPEN: | ||
2644 | nfsd4_encode_open(resp, op->status, &op->u.open); | ||
2645 | break; | ||
2646 | case OP_OPEN_CONFIRM: | ||
2647 | nfsd4_encode_open_confirm(resp, op->status, &op->u.open_confirm); | ||
2648 | break; | ||
2649 | case OP_OPEN_DOWNGRADE: | ||
2650 | nfsd4_encode_open_downgrade(resp, op->status, &op->u.open_downgrade); | ||
2651 | break; | ||
2652 | case OP_PUTFH: | ||
2653 | break; | ||
2654 | case OP_PUTROOTFH: | ||
2655 | break; | ||
2656 | case OP_READ: | ||
2657 | op->status = nfsd4_encode_read(resp, op->status, &op->u.read); | ||
2658 | break; | ||
2659 | case OP_READDIR: | ||
2660 | op->status = nfsd4_encode_readdir(resp, op->status, &op->u.readdir); | ||
2661 | break; | ||
2662 | case OP_READLINK: | ||
2663 | op->status = nfsd4_encode_readlink(resp, op->status, &op->u.readlink); | ||
2664 | break; | ||
2665 | case OP_REMOVE: | ||
2666 | nfsd4_encode_remove(resp, op->status, &op->u.remove); | ||
2667 | break; | ||
2668 | case OP_RENAME: | ||
2669 | nfsd4_encode_rename(resp, op->status, &op->u.rename); | ||
2670 | break; | ||
2671 | case OP_RENEW: | ||
2672 | break; | ||
2673 | case OP_RESTOREFH: | ||
2674 | break; | ||
2675 | case OP_SAVEFH: | ||
2676 | break; | ||
2677 | case OP_SECINFO: | ||
2678 | nfsd4_encode_secinfo(resp, op->status, &op->u.secinfo); | ||
2679 | break; | ||
2680 | case OP_SETATTR: | ||
2681 | nfsd4_encode_setattr(resp, op->status, &op->u.setattr); | ||
2682 | break; | ||
2683 | case OP_SETCLIENTID: | ||
2684 | nfsd4_encode_setclientid(resp, op->status, &op->u.setclientid); | ||
2685 | break; | ||
2686 | case OP_SETCLIENTID_CONFIRM: | ||
2687 | break; | ||
2688 | case OP_VERIFY: | ||
2689 | break; | ||
2690 | case OP_WRITE: | ||
2691 | nfsd4_encode_write(resp, op->status, &op->u.write); | ||
2692 | break; | ||
2693 | case OP_RELEASE_LOCKOWNER: | ||
2694 | break; | ||
2695 | default: | ||
2696 | break; | ||
2697 | } | ||
2698 | |||
2699 | /* | 2635 | /* |
2700 | * Note: We write the status directly, instead of using WRITE32(), | 2636 | * Note: We write the status directly, instead of using WRITE32(), |
2701 | * since it is already in network byte order. | 2637 | * since it is already in network byte order. |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 5ac00c4fee91..1955a2702e60 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -310,9 +310,12 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size) | |||
310 | 310 | ||
311 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | 311 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) |
312 | { | 312 | { |
313 | __be32 server_ip; | 313 | struct sockaddr_in sin = { |
314 | char *fo_path, c; | 314 | .sin_family = AF_INET, |
315 | }; | ||
315 | int b1, b2, b3, b4; | 316 | int b1, b2, b3, b4; |
317 | char c; | ||
318 | char *fo_path; | ||
316 | 319 | ||
317 | /* sanity check */ | 320 | /* sanity check */ |
318 | if (size == 0) | 321 | if (size == 0) |
@@ -326,11 +329,13 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | |||
326 | return -EINVAL; | 329 | return -EINVAL; |
327 | 330 | ||
328 | /* get ipv4 address */ | 331 | /* get ipv4 address */ |
329 | if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) | 332 | if (sscanf(fo_path, NIPQUAD_FMT "%c", &b1, &b2, &b3, &b4, &c) != 4) |
330 | return -EINVAL; | 333 | return -EINVAL; |
331 | server_ip = htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4); | 334 | if (b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255) |
335 | return -EINVAL; | ||
336 | sin.sin_addr.s_addr = htonl((b1 << 24) | (b2 << 16) | (b3 << 8) | b4); | ||
332 | 337 | ||
333 | return nlmsvc_unlock_all_by_ip(server_ip); | 338 | return nlmsvc_unlock_all_by_ip((struct sockaddr *)&sin); |
334 | } | 339 | } |
335 | 340 | ||
336 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) | 341 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) |
@@ -450,22 +455,26 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) | |||
450 | int i; | 455 | int i; |
451 | int rv; | 456 | int rv; |
452 | int len; | 457 | int len; |
453 | int npools = nfsd_nrpools(); | 458 | int npools; |
454 | int *nthreads; | 459 | int *nthreads; |
455 | 460 | ||
461 | mutex_lock(&nfsd_mutex); | ||
462 | npools = nfsd_nrpools(); | ||
456 | if (npools == 0) { | 463 | if (npools == 0) { |
457 | /* | 464 | /* |
458 | * NFS is shut down. The admin can start it by | 465 | * NFS is shut down. The admin can start it by |
459 | * writing to the threads file but NOT the pool_threads | 466 | * writing to the threads file but NOT the pool_threads |
460 | * file, sorry. Report zero threads. | 467 | * file, sorry. Report zero threads. |
461 | */ | 468 | */ |
469 | mutex_unlock(&nfsd_mutex); | ||
462 | strcpy(buf, "0\n"); | 470 | strcpy(buf, "0\n"); |
463 | return strlen(buf); | 471 | return strlen(buf); |
464 | } | 472 | } |
465 | 473 | ||
466 | nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL); | 474 | nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL); |
475 | rv = -ENOMEM; | ||
467 | if (nthreads == NULL) | 476 | if (nthreads == NULL) |
468 | return -ENOMEM; | 477 | goto out_free; |
469 | 478 | ||
470 | if (size > 0) { | 479 | if (size > 0) { |
471 | for (i = 0; i < npools; i++) { | 480 | for (i = 0; i < npools; i++) { |
@@ -496,14 +505,16 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) | |||
496 | mesg += len; | 505 | mesg += len; |
497 | } | 506 | } |
498 | 507 | ||
508 | mutex_unlock(&nfsd_mutex); | ||
499 | return (mesg-buf); | 509 | return (mesg-buf); |
500 | 510 | ||
501 | out_free: | 511 | out_free: |
502 | kfree(nthreads); | 512 | kfree(nthreads); |
513 | mutex_unlock(&nfsd_mutex); | ||
503 | return rv; | 514 | return rv; |
504 | } | 515 | } |
505 | 516 | ||
506 | static ssize_t write_versions(struct file *file, char *buf, size_t size) | 517 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) |
507 | { | 518 | { |
508 | /* | 519 | /* |
509 | * Format: | 520 | * Format: |
@@ -566,14 +577,23 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size) | |||
566 | return len; | 577 | return len; |
567 | } | 578 | } |
568 | 579 | ||
569 | static ssize_t write_ports(struct file *file, char *buf, size_t size) | 580 | static ssize_t write_versions(struct file *file, char *buf, size_t size) |
581 | { | ||
582 | ssize_t rv; | ||
583 | |||
584 | mutex_lock(&nfsd_mutex); | ||
585 | rv = __write_versions(file, buf, size); | ||
586 | mutex_unlock(&nfsd_mutex); | ||
587 | return rv; | ||
588 | } | ||
589 | |||
590 | static ssize_t __write_ports(struct file *file, char *buf, size_t size) | ||
570 | { | 591 | { |
571 | if (size == 0) { | 592 | if (size == 0) { |
572 | int len = 0; | 593 | int len = 0; |
573 | lock_kernel(); | 594 | |
574 | if (nfsd_serv) | 595 | if (nfsd_serv) |
575 | len = svc_xprt_names(nfsd_serv, buf, 0); | 596 | len = svc_xprt_names(nfsd_serv, buf, 0); |
576 | unlock_kernel(); | ||
577 | return len; | 597 | return len; |
578 | } | 598 | } |
579 | /* Either a single 'fd' number is written, in which | 599 | /* Either a single 'fd' number is written, in which |
@@ -603,9 +623,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
603 | /* Decrease the count, but don't shutdown the | 623 | /* Decrease the count, but don't shutdown the |
604 | * the service | 624 | * the service |
605 | */ | 625 | */ |
606 | lock_kernel(); | ||
607 | nfsd_serv->sv_nrthreads--; | 626 | nfsd_serv->sv_nrthreads--; |
608 | unlock_kernel(); | ||
609 | } | 627 | } |
610 | return err < 0 ? err : 0; | 628 | return err < 0 ? err : 0; |
611 | } | 629 | } |
@@ -614,10 +632,8 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
614 | int len = 0; | 632 | int len = 0; |
615 | if (!toclose) | 633 | if (!toclose) |
616 | return -ENOMEM; | 634 | return -ENOMEM; |
617 | lock_kernel(); | ||
618 | if (nfsd_serv) | 635 | if (nfsd_serv) |
619 | len = svc_sock_names(buf, nfsd_serv, toclose); | 636 | len = svc_sock_names(buf, nfsd_serv, toclose); |
620 | unlock_kernel(); | ||
621 | if (len >= 0) | 637 | if (len >= 0) |
622 | lockd_down(); | 638 | lockd_down(); |
623 | kfree(toclose); | 639 | kfree(toclose); |
@@ -655,7 +671,6 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
655 | if (sscanf(&buf[1], "%15s %4d", transport, &port) == 2) { | 671 | if (sscanf(&buf[1], "%15s %4d", transport, &port) == 2) { |
656 | if (port == 0) | 672 | if (port == 0) |
657 | return -EINVAL; | 673 | return -EINVAL; |
658 | lock_kernel(); | ||
659 | if (nfsd_serv) { | 674 | if (nfsd_serv) { |
660 | xprt = svc_find_xprt(nfsd_serv, transport, | 675 | xprt = svc_find_xprt(nfsd_serv, transport, |
661 | AF_UNSPEC, port); | 676 | AF_UNSPEC, port); |
@@ -666,13 +681,23 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
666 | } else | 681 | } else |
667 | err = -ENOTCONN; | 682 | err = -ENOTCONN; |
668 | } | 683 | } |
669 | unlock_kernel(); | ||
670 | return err < 0 ? err : 0; | 684 | return err < 0 ? err : 0; |
671 | } | 685 | } |
672 | } | 686 | } |
673 | return -EINVAL; | 687 | return -EINVAL; |
674 | } | 688 | } |
675 | 689 | ||
690 | static ssize_t write_ports(struct file *file, char *buf, size_t size) | ||
691 | { | ||
692 | ssize_t rv; | ||
693 | |||
694 | mutex_lock(&nfsd_mutex); | ||
695 | rv = __write_ports(file, buf, size); | ||
696 | mutex_unlock(&nfsd_mutex); | ||
697 | return rv; | ||
698 | } | ||
699 | |||
700 | |||
676 | int nfsd_max_blksize; | 701 | int nfsd_max_blksize; |
677 | 702 | ||
678 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | 703 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) |
@@ -691,13 +716,13 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | |||
691 | if (bsize > NFSSVC_MAXBLKSIZE) | 716 | if (bsize > NFSSVC_MAXBLKSIZE) |
692 | bsize = NFSSVC_MAXBLKSIZE; | 717 | bsize = NFSSVC_MAXBLKSIZE; |
693 | bsize &= ~(1024-1); | 718 | bsize &= ~(1024-1); |
694 | lock_kernel(); | 719 | mutex_lock(&nfsd_mutex); |
695 | if (nfsd_serv && nfsd_serv->sv_nrthreads) { | 720 | if (nfsd_serv && nfsd_serv->sv_nrthreads) { |
696 | unlock_kernel(); | 721 | mutex_unlock(&nfsd_mutex); |
697 | return -EBUSY; | 722 | return -EBUSY; |
698 | } | 723 | } |
699 | nfsd_max_blksize = bsize; | 724 | nfsd_max_blksize = bsize; |
700 | unlock_kernel(); | 725 | mutex_unlock(&nfsd_mutex); |
701 | } | 726 | } |
702 | return sprintf(buf, "%d\n", nfsd_max_blksize); | 727 | return sprintf(buf, "%d\n", nfsd_max_blksize); |
703 | } | 728 | } |
@@ -705,16 +730,17 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | |||
705 | #ifdef CONFIG_NFSD_V4 | 730 | #ifdef CONFIG_NFSD_V4 |
706 | extern time_t nfs4_leasetime(void); | 731 | extern time_t nfs4_leasetime(void); |
707 | 732 | ||
708 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | 733 | static ssize_t __write_leasetime(struct file *file, char *buf, size_t size) |
709 | { | 734 | { |
710 | /* if size > 10 seconds, call | 735 | /* if size > 10 seconds, call |
711 | * nfs4_reset_lease() then write out the new lease (seconds) as reply | 736 | * nfs4_reset_lease() then write out the new lease (seconds) as reply |
712 | */ | 737 | */ |
713 | char *mesg = buf; | 738 | char *mesg = buf; |
714 | int rv; | 739 | int rv, lease; |
715 | 740 | ||
716 | if (size > 0) { | 741 | if (size > 0) { |
717 | int lease; | 742 | if (nfsd_serv) |
743 | return -EBUSY; | ||
718 | rv = get_int(&mesg, &lease); | 744 | rv = get_int(&mesg, &lease); |
719 | if (rv) | 745 | if (rv) |
720 | return rv; | 746 | return rv; |
@@ -726,24 +752,52 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | |||
726 | return strlen(buf); | 752 | return strlen(buf); |
727 | } | 753 | } |
728 | 754 | ||
729 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | 755 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
756 | { | ||
757 | ssize_t rv; | ||
758 | |||
759 | mutex_lock(&nfsd_mutex); | ||
760 | rv = __write_leasetime(file, buf, size); | ||
761 | mutex_unlock(&nfsd_mutex); | ||
762 | return rv; | ||
763 | } | ||
764 | |||
765 | extern char *nfs4_recoverydir(void); | ||
766 | |||
767 | static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size) | ||
730 | { | 768 | { |
731 | char *mesg = buf; | 769 | char *mesg = buf; |
732 | char *recdir; | 770 | char *recdir; |
733 | int len, status; | 771 | int len, status; |
734 | 772 | ||
735 | if (size == 0 || size > PATH_MAX || buf[size-1] != '\n') | 773 | if (size > 0) { |
736 | return -EINVAL; | 774 | if (nfsd_serv) |
737 | buf[size-1] = 0; | 775 | return -EBUSY; |
776 | if (size > PATH_MAX || buf[size-1] != '\n') | ||
777 | return -EINVAL; | ||
778 | buf[size-1] = 0; | ||
738 | 779 | ||
739 | recdir = mesg; | 780 | recdir = mesg; |
740 | len = qword_get(&mesg, recdir, size); | 781 | len = qword_get(&mesg, recdir, size); |
741 | if (len <= 0) | 782 | if (len <= 0) |
742 | return -EINVAL; | 783 | return -EINVAL; |
743 | 784 | ||
744 | status = nfs4_reset_recoverydir(recdir); | 785 | status = nfs4_reset_recoverydir(recdir); |
786 | } | ||
787 | sprintf(buf, "%s\n", nfs4_recoverydir()); | ||
745 | return strlen(buf); | 788 | return strlen(buf); |
746 | } | 789 | } |
790 | |||
791 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | ||
792 | { | ||
793 | ssize_t rv; | ||
794 | |||
795 | mutex_lock(&nfsd_mutex); | ||
796 | rv = __write_recoverydir(file, buf, size); | ||
797 | mutex_unlock(&nfsd_mutex); | ||
798 | return rv; | ||
799 | } | ||
800 | |||
747 | #endif | 801 | #endif |
748 | 802 | ||
749 | /*----------------------------------------------------------------------------*/ | 803 | /*----------------------------------------------------------------------------*/ |
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 100ae5641162..f45451eb1e38 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c | |||
@@ -176,9 +176,24 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) | |||
176 | if (IS_ERR(exp)) | 176 | if (IS_ERR(exp)) |
177 | return nfserrno(PTR_ERR(exp)); | 177 | return nfserrno(PTR_ERR(exp)); |
178 | 178 | ||
179 | error = nfsd_setuser_and_check_port(rqstp, exp); | 179 | if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { |
180 | if (error) | 180 | /* Elevate privileges so that the lack of 'r' or 'x' |
181 | goto out; | 181 | * permission on some parent directory will |
182 | * not stop exportfs_decode_fh from being able | ||
183 | * to reconnect a directory into the dentry cache. | ||
184 | * The same problem can affect "SUBTREECHECK" exports, | ||
185 | * but as nfsd_acceptable depends on correct | ||
186 | * access control settings being in effect, we cannot | ||
187 | * fix that case easily. | ||
188 | */ | ||
189 | current->cap_effective = | ||
190 | cap_raise_nfsd_set(current->cap_effective, | ||
191 | current->cap_permitted); | ||
192 | } else { | ||
193 | error = nfsd_setuser_and_check_port(rqstp, exp); | ||
194 | if (error) | ||
195 | goto out; | ||
196 | } | ||
182 | 197 | ||
183 | /* | 198 | /* |
184 | * Look up the dentry using the NFS file handle. | 199 | * Look up the dentry using the NFS file handle. |
@@ -215,6 +230,14 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) | |||
215 | goto out; | 230 | goto out; |
216 | } | 231 | } |
217 | 232 | ||
233 | if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { | ||
234 | error = nfsd_setuser_and_check_port(rqstp, exp); | ||
235 | if (error) { | ||
236 | dput(dentry); | ||
237 | goto out; | ||
238 | } | ||
239 | } | ||
240 | |||
218 | if (S_ISDIR(dentry->d_inode->i_mode) && | 241 | if (S_ISDIR(dentry->d_inode->i_mode) && |
219 | (dentry->d_flags & DCACHE_DISCONNECTED)) { | 242 | (dentry->d_flags & DCACHE_DISCONNECTED)) { |
220 | printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n", | 243 | printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n", |
@@ -279,7 +302,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) | |||
279 | if (error) | 302 | if (error) |
280 | goto out; | 303 | goto out; |
281 | 304 | ||
282 | if (!(access & MAY_LOCK)) { | 305 | if (!(access & NFSD_MAY_LOCK)) { |
283 | /* | 306 | /* |
284 | * pseudoflavor restrictions are not enforced on NLM, | 307 | * pseudoflavor restrictions are not enforced on NLM, |
285 | * which clients virtually always use auth_sys for, | 308 | * which clients virtually always use auth_sys for, |
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 6cfc96a12483..0766f95d236a 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c | |||
@@ -65,7 +65,7 @@ nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, | |||
65 | dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); | 65 | dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); |
66 | 66 | ||
67 | fh_copy(&resp->fh, &argp->fh); | 67 | fh_copy(&resp->fh, &argp->fh); |
68 | nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP); | 68 | nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); |
69 | return nfsd_return_attrs(nfserr, resp); | 69 | return nfsd_return_attrs(nfserr, resp); |
70 | } | 70 | } |
71 | 71 | ||
@@ -215,11 +215,11 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, | |||
215 | SVCFH_fmt(dirfhp), argp->len, argp->name); | 215 | SVCFH_fmt(dirfhp), argp->len, argp->name); |
216 | 216 | ||
217 | /* First verify the parent file handle */ | 217 | /* First verify the parent file handle */ |
218 | nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, MAY_EXEC); | 218 | nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC); |
219 | if (nfserr) | 219 | if (nfserr) |
220 | goto done; /* must fh_put dirfhp even on error */ | 220 | goto done; /* must fh_put dirfhp even on error */ |
221 | 221 | ||
222 | /* Check for MAY_WRITE in nfsd_create if necessary */ | 222 | /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */ |
223 | 223 | ||
224 | nfserr = nfserr_acces; | 224 | nfserr = nfserr_acces; |
225 | if (!argp->len) | 225 | if (!argp->len) |
@@ -281,7 +281,7 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, | |||
281 | nfserr = nfsd_permission(rqstp, | 281 | nfserr = nfsd_permission(rqstp, |
282 | newfhp->fh_export, | 282 | newfhp->fh_export, |
283 | newfhp->fh_dentry, | 283 | newfhp->fh_dentry, |
284 | MAY_WRITE|MAY_LOCAL_ACCESS); | 284 | NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS); |
285 | if (nfserr && nfserr != nfserr_rofs) | 285 | if (nfserr && nfserr != nfserr_rofs) |
286 | goto out_unlock; | 286 | goto out_unlock; |
287 | } | 287 | } |
@@ -614,6 +614,7 @@ nfserrno (int errno) | |||
614 | #endif | 614 | #endif |
615 | { nfserr_stale, -ESTALE }, | 615 | { nfserr_stale, -ESTALE }, |
616 | { nfserr_jukebox, -ETIMEDOUT }, | 616 | { nfserr_jukebox, -ETIMEDOUT }, |
617 | { nfserr_jukebox, -ERESTARTSYS }, | ||
617 | { nfserr_dropit, -EAGAIN }, | 618 | { nfserr_dropit, -EAGAIN }, |
618 | { nfserr_dropit, -ENOMEM }, | 619 | { nfserr_dropit, -ENOMEM }, |
619 | { nfserr_badname, -ESRCH }, | 620 | { nfserr_badname, -ESRCH }, |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 941041f4b136..80292ff5e924 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
22 | #include <linux/freezer.h> | 22 | #include <linux/freezer.h> |
23 | #include <linux/fs_struct.h> | 23 | #include <linux/fs_struct.h> |
24 | #include <linux/kthread.h> | ||
24 | 25 | ||
25 | #include <linux/sunrpc/types.h> | 26 | #include <linux/sunrpc/types.h> |
26 | #include <linux/sunrpc/stats.h> | 27 | #include <linux/sunrpc/stats.h> |
@@ -36,28 +37,38 @@ | |||
36 | 37 | ||
37 | #define NFSDDBG_FACILITY NFSDDBG_SVC | 38 | #define NFSDDBG_FACILITY NFSDDBG_SVC |
38 | 39 | ||
39 | /* these signals will be delivered to an nfsd thread | ||
40 | * when handling a request | ||
41 | */ | ||
42 | #define ALLOWED_SIGS (sigmask(SIGKILL)) | ||
43 | /* these signals will be delivered to an nfsd thread | ||
44 | * when not handling a request. i.e. when waiting | ||
45 | */ | ||
46 | #define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT)) | ||
47 | /* if the last thread dies with SIGHUP, then the exports table is | ||
48 | * left unchanged ( like 2.4-{0-9} ). Any other signal will clear | ||
49 | * the exports table (like 2.2). | ||
50 | */ | ||
51 | #define SIG_NOCLEAN SIGHUP | ||
52 | |||
53 | extern struct svc_program nfsd_program; | 40 | extern struct svc_program nfsd_program; |
54 | static void nfsd(struct svc_rqst *rqstp); | 41 | static int nfsd(void *vrqstp); |
55 | struct timeval nfssvc_boot; | 42 | struct timeval nfssvc_boot; |
56 | struct svc_serv *nfsd_serv; | ||
57 | static atomic_t nfsd_busy; | 43 | static atomic_t nfsd_busy; |
58 | static unsigned long nfsd_last_call; | 44 | static unsigned long nfsd_last_call; |
59 | static DEFINE_SPINLOCK(nfsd_call_lock); | 45 | static DEFINE_SPINLOCK(nfsd_call_lock); |
60 | 46 | ||
47 | /* | ||
48 | * nfsd_mutex protects nfsd_serv -- both the pointer itself and the members | ||
49 | * of the svc_serv struct. In particular, ->sv_nrthreads but also to some | ||
50 | * extent ->sv_temp_socks and ->sv_permsocks. It also protects nfsdstats.th_cnt | ||
51 | * | ||
52 | * If (out side the lock) nfsd_serv is non-NULL, then it must point to a | ||
53 | * properly initialised 'struct svc_serv' with ->sv_nrthreads > 0. That number | ||
54 | * of nfsd threads must exist and each must listed in ->sp_all_threads in each | ||
55 | * entry of ->sv_pools[]. | ||
56 | * | ||
57 | * Transitions of the thread count between zero and non-zero are of particular | ||
58 | * interest since the svc_serv needs to be created and initialized at that | ||
59 | * point, or freed. | ||
60 | * | ||
61 | * Finally, the nfsd_mutex also protects some of the global variables that are | ||
62 | * accessed when nfsd starts and that are settable via the write_* routines in | ||
63 | * nfsctl.c. In particular: | ||
64 | * | ||
65 | * user_recovery_dirname | ||
66 | * user_lease_time | ||
67 | * nfsd_versions | ||
68 | */ | ||
69 | DEFINE_MUTEX(nfsd_mutex); | ||
70 | struct svc_serv *nfsd_serv; | ||
71 | |||
61 | #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) | 72 | #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) |
62 | static struct svc_stat nfsd_acl_svcstats; | 73 | static struct svc_stat nfsd_acl_svcstats; |
63 | static struct svc_version * nfsd_acl_version[] = { | 74 | static struct svc_version * nfsd_acl_version[] = { |
@@ -145,13 +156,14 @@ int nfsd_vers(int vers, enum vers_op change) | |||
145 | 156 | ||
146 | int nfsd_nrthreads(void) | 157 | int nfsd_nrthreads(void) |
147 | { | 158 | { |
148 | if (nfsd_serv == NULL) | 159 | int rv = 0; |
149 | return 0; | 160 | mutex_lock(&nfsd_mutex); |
150 | else | 161 | if (nfsd_serv) |
151 | return nfsd_serv->sv_nrthreads; | 162 | rv = nfsd_serv->sv_nrthreads; |
163 | mutex_unlock(&nfsd_mutex); | ||
164 | return rv; | ||
152 | } | 165 | } |
153 | 166 | ||
154 | static int killsig; /* signal that was used to kill last nfsd */ | ||
155 | static void nfsd_last_thread(struct svc_serv *serv) | 167 | static void nfsd_last_thread(struct svc_serv *serv) |
156 | { | 168 | { |
157 | /* When last nfsd thread exits we need to do some clean-up */ | 169 | /* When last nfsd thread exits we need to do some clean-up */ |
@@ -162,11 +174,9 @@ static void nfsd_last_thread(struct svc_serv *serv) | |||
162 | nfsd_racache_shutdown(); | 174 | nfsd_racache_shutdown(); |
163 | nfs4_state_shutdown(); | 175 | nfs4_state_shutdown(); |
164 | 176 | ||
165 | printk(KERN_WARNING "nfsd: last server has exited\n"); | 177 | printk(KERN_WARNING "nfsd: last server has exited, flushing export " |
166 | if (killsig != SIG_NOCLEAN) { | 178 | "cache\n"); |
167 | printk(KERN_WARNING "nfsd: unexporting all filesystems\n"); | 179 | nfsd_export_flush(); |
168 | nfsd_export_flush(); | ||
169 | } | ||
170 | } | 180 | } |
171 | 181 | ||
172 | void nfsd_reset_versions(void) | 182 | void nfsd_reset_versions(void) |
@@ -190,13 +200,14 @@ void nfsd_reset_versions(void) | |||
190 | } | 200 | } |
191 | } | 201 | } |
192 | 202 | ||
203 | |||
193 | int nfsd_create_serv(void) | 204 | int nfsd_create_serv(void) |
194 | { | 205 | { |
195 | int err = 0; | 206 | int err = 0; |
196 | lock_kernel(); | 207 | |
208 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); | ||
197 | if (nfsd_serv) { | 209 | if (nfsd_serv) { |
198 | svc_get(nfsd_serv); | 210 | svc_get(nfsd_serv); |
199 | unlock_kernel(); | ||
200 | return 0; | 211 | return 0; |
201 | } | 212 | } |
202 | if (nfsd_max_blksize == 0) { | 213 | if (nfsd_max_blksize == 0) { |
@@ -217,13 +228,11 @@ int nfsd_create_serv(void) | |||
217 | } | 228 | } |
218 | 229 | ||
219 | atomic_set(&nfsd_busy, 0); | 230 | atomic_set(&nfsd_busy, 0); |
220 | nfsd_serv = svc_create_pooled(&nfsd_program, | 231 | nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, |
221 | nfsd_max_blksize, | 232 | nfsd_last_thread, nfsd, THIS_MODULE); |
222 | nfsd_last_thread, | ||
223 | nfsd, SIG_NOCLEAN, THIS_MODULE); | ||
224 | if (nfsd_serv == NULL) | 233 | if (nfsd_serv == NULL) |
225 | err = -ENOMEM; | 234 | err = -ENOMEM; |
226 | unlock_kernel(); | 235 | |
227 | do_gettimeofday(&nfssvc_boot); /* record boot time */ | 236 | do_gettimeofday(&nfssvc_boot); /* record boot time */ |
228 | return err; | 237 | return err; |
229 | } | 238 | } |
@@ -282,6 +291,8 @@ int nfsd_set_nrthreads(int n, int *nthreads) | |||
282 | int tot = 0; | 291 | int tot = 0; |
283 | int err = 0; | 292 | int err = 0; |
284 | 293 | ||
294 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); | ||
295 | |||
285 | if (nfsd_serv == NULL || n <= 0) | 296 | if (nfsd_serv == NULL || n <= 0) |
286 | return 0; | 297 | return 0; |
287 | 298 | ||
@@ -316,7 +327,6 @@ int nfsd_set_nrthreads(int n, int *nthreads) | |||
316 | nthreads[0] = 1; | 327 | nthreads[0] = 1; |
317 | 328 | ||
318 | /* apply the new numbers */ | 329 | /* apply the new numbers */ |
319 | lock_kernel(); | ||
320 | svc_get(nfsd_serv); | 330 | svc_get(nfsd_serv); |
321 | for (i = 0; i < n; i++) { | 331 | for (i = 0; i < n; i++) { |
322 | err = svc_set_num_threads(nfsd_serv, &nfsd_serv->sv_pools[i], | 332 | err = svc_set_num_threads(nfsd_serv, &nfsd_serv->sv_pools[i], |
@@ -325,7 +335,6 @@ int nfsd_set_nrthreads(int n, int *nthreads) | |||
325 | break; | 335 | break; |
326 | } | 336 | } |
327 | svc_destroy(nfsd_serv); | 337 | svc_destroy(nfsd_serv); |
328 | unlock_kernel(); | ||
329 | 338 | ||
330 | return err; | 339 | return err; |
331 | } | 340 | } |
@@ -334,8 +343,8 @@ int | |||
334 | nfsd_svc(unsigned short port, int nrservs) | 343 | nfsd_svc(unsigned short port, int nrservs) |
335 | { | 344 | { |
336 | int error; | 345 | int error; |
337 | 346 | ||
338 | lock_kernel(); | 347 | mutex_lock(&nfsd_mutex); |
339 | dprintk("nfsd: creating service\n"); | 348 | dprintk("nfsd: creating service\n"); |
340 | error = -EINVAL; | 349 | error = -EINVAL; |
341 | if (nrservs <= 0) | 350 | if (nrservs <= 0) |
@@ -363,7 +372,7 @@ nfsd_svc(unsigned short port, int nrservs) | |||
363 | failure: | 372 | failure: |
364 | svc_destroy(nfsd_serv); /* Release server */ | 373 | svc_destroy(nfsd_serv); /* Release server */ |
365 | out: | 374 | out: |
366 | unlock_kernel(); | 375 | mutex_unlock(&nfsd_mutex); |
367 | return error; | 376 | return error; |
368 | } | 377 | } |
369 | 378 | ||
@@ -391,18 +400,17 @@ update_thread_usage(int busy_threads) | |||
391 | /* | 400 | /* |
392 | * This is the NFS server kernel thread | 401 | * This is the NFS server kernel thread |
393 | */ | 402 | */ |
394 | static void | 403 | static int |
395 | nfsd(struct svc_rqst *rqstp) | 404 | nfsd(void *vrqstp) |
396 | { | 405 | { |
406 | struct svc_rqst *rqstp = (struct svc_rqst *) vrqstp; | ||
397 | struct fs_struct *fsp; | 407 | struct fs_struct *fsp; |
398 | int err; | 408 | int err, preverr = 0; |
399 | sigset_t shutdown_mask, allowed_mask; | ||
400 | 409 | ||
401 | /* Lock module and set up kernel thread */ | 410 | /* Lock module and set up kernel thread */ |
402 | lock_kernel(); | 411 | mutex_lock(&nfsd_mutex); |
403 | daemonize("nfsd"); | ||
404 | 412 | ||
405 | /* After daemonize() this kernel thread shares current->fs | 413 | /* At this point, the thread shares current->fs |
406 | * with the init process. We need to create files with a | 414 | * with the init process. We need to create files with a |
407 | * umask of 0 instead of init's umask. */ | 415 | * umask of 0 instead of init's umask. */ |
408 | fsp = copy_fs_struct(current->fs); | 416 | fsp = copy_fs_struct(current->fs); |
@@ -414,14 +422,17 @@ nfsd(struct svc_rqst *rqstp) | |||
414 | current->fs = fsp; | 422 | current->fs = fsp; |
415 | current->fs->umask = 0; | 423 | current->fs->umask = 0; |
416 | 424 | ||
417 | siginitsetinv(&shutdown_mask, SHUTDOWN_SIGS); | 425 | /* |
418 | siginitsetinv(&allowed_mask, ALLOWED_SIGS); | 426 | * thread is spawned with all signals set to SIG_IGN, re-enable |
427 | * the ones that will bring down the thread | ||
428 | */ | ||
429 | allow_signal(SIGKILL); | ||
430 | allow_signal(SIGHUP); | ||
431 | allow_signal(SIGINT); | ||
432 | allow_signal(SIGQUIT); | ||
419 | 433 | ||
420 | nfsdstats.th_cnt++; | 434 | nfsdstats.th_cnt++; |
421 | 435 | mutex_unlock(&nfsd_mutex); | |
422 | rqstp->rq_task = current; | ||
423 | |||
424 | unlock_kernel(); | ||
425 | 436 | ||
426 | /* | 437 | /* |
427 | * We want less throttling in balance_dirty_pages() so that nfs to | 438 | * We want less throttling in balance_dirty_pages() so that nfs to |
@@ -435,26 +446,30 @@ nfsd(struct svc_rqst *rqstp) | |||
435 | * The main request loop | 446 | * The main request loop |
436 | */ | 447 | */ |
437 | for (;;) { | 448 | for (;;) { |
438 | /* Block all but the shutdown signals */ | ||
439 | sigprocmask(SIG_SETMASK, &shutdown_mask, NULL); | ||
440 | |||
441 | /* | 449 | /* |
442 | * Find a socket with data available and call its | 450 | * Find a socket with data available and call its |
443 | * recvfrom routine. | 451 | * recvfrom routine. |
444 | */ | 452 | */ |
445 | while ((err = svc_recv(rqstp, 60*60*HZ)) == -EAGAIN) | 453 | while ((err = svc_recv(rqstp, 60*60*HZ)) == -EAGAIN) |
446 | ; | 454 | ; |
447 | if (err < 0) | 455 | if (err == -EINTR) |
448 | break; | 456 | break; |
457 | else if (err < 0) { | ||
458 | if (err != preverr) { | ||
459 | printk(KERN_WARNING "%s: unexpected error " | ||
460 | "from svc_recv (%d)\n", __func__, -err); | ||
461 | preverr = err; | ||
462 | } | ||
463 | schedule_timeout_uninterruptible(HZ); | ||
464 | continue; | ||
465 | } | ||
466 | |||
449 | update_thread_usage(atomic_read(&nfsd_busy)); | 467 | update_thread_usage(atomic_read(&nfsd_busy)); |
450 | atomic_inc(&nfsd_busy); | 468 | atomic_inc(&nfsd_busy); |
451 | 469 | ||
452 | /* Lock the export hash tables for reading. */ | 470 | /* Lock the export hash tables for reading. */ |
453 | exp_readlock(); | 471 | exp_readlock(); |
454 | 472 | ||
455 | /* Process request with signals blocked. */ | ||
456 | sigprocmask(SIG_SETMASK, &allowed_mask, NULL); | ||
457 | |||
458 | svc_process(rqstp); | 473 | svc_process(rqstp); |
459 | 474 | ||
460 | /* Unlock export hash tables */ | 475 | /* Unlock export hash tables */ |
@@ -463,22 +478,10 @@ nfsd(struct svc_rqst *rqstp) | |||
463 | atomic_dec(&nfsd_busy); | 478 | atomic_dec(&nfsd_busy); |
464 | } | 479 | } |
465 | 480 | ||
466 | if (err != -EINTR) { | ||
467 | printk(KERN_WARNING "nfsd: terminating on error %d\n", -err); | ||
468 | } else { | ||
469 | unsigned int signo; | ||
470 | |||
471 | for (signo = 1; signo <= _NSIG; signo++) | ||
472 | if (sigismember(¤t->pending.signal, signo) && | ||
473 | !sigismember(¤t->blocked, signo)) | ||
474 | break; | ||
475 | killsig = signo; | ||
476 | } | ||
477 | /* Clear signals before calling svc_exit_thread() */ | 481 | /* Clear signals before calling svc_exit_thread() */ |
478 | flush_signals(current); | 482 | flush_signals(current); |
479 | 483 | ||
480 | lock_kernel(); | 484 | mutex_lock(&nfsd_mutex); |
481 | |||
482 | nfsdstats.th_cnt --; | 485 | nfsdstats.th_cnt --; |
483 | 486 | ||
484 | out: | 487 | out: |
@@ -486,8 +489,9 @@ out: | |||
486 | svc_exit_thread(rqstp); | 489 | svc_exit_thread(rqstp); |
487 | 490 | ||
488 | /* Release module */ | 491 | /* Release module */ |
489 | unlock_kernel(); | 492 | mutex_unlock(&nfsd_mutex); |
490 | module_put_and_exit(0); | 493 | module_put_and_exit(0); |
494 | return 0; | ||
491 | } | 495 | } |
492 | 496 | ||
493 | static __be32 map_new_errors(u32 vers, __be32 nfserr) | 497 | static __be32 map_new_errors(u32 vers, __be32 nfserr) |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index a3a291f771f4..0f4481e0502d 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -144,7 +144,7 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
144 | dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name); | 144 | dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name); |
145 | 145 | ||
146 | /* Obtain dentry and export. */ | 146 | /* Obtain dentry and export. */ |
147 | err = fh_verify(rqstp, fhp, S_IFDIR, MAY_EXEC); | 147 | err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC); |
148 | if (err) | 148 | if (err) |
149 | return err; | 149 | return err; |
150 | 150 | ||
@@ -262,14 +262,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
262 | { | 262 | { |
263 | struct dentry *dentry; | 263 | struct dentry *dentry; |
264 | struct inode *inode; | 264 | struct inode *inode; |
265 | int accmode = MAY_SATTR; | 265 | int accmode = NFSD_MAY_SATTR; |
266 | int ftype = 0; | 266 | int ftype = 0; |
267 | __be32 err; | 267 | __be32 err; |
268 | int host_err; | 268 | int host_err; |
269 | int size_change = 0; | 269 | int size_change = 0; |
270 | 270 | ||
271 | if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE)) | 271 | if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE)) |
272 | accmode |= MAY_WRITE|MAY_OWNER_OVERRIDE; | 272 | accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE; |
273 | if (iap->ia_valid & ATTR_SIZE) | 273 | if (iap->ia_valid & ATTR_SIZE) |
274 | ftype = S_IFREG; | 274 | ftype = S_IFREG; |
275 | 275 | ||
@@ -331,7 +331,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
331 | */ | 331 | */ |
332 | if (iap->ia_valid & ATTR_SIZE) { | 332 | if (iap->ia_valid & ATTR_SIZE) { |
333 | if (iap->ia_size < inode->i_size) { | 333 | if (iap->ia_size < inode->i_size) { |
334 | err = nfsd_permission(rqstp, fhp->fh_export, dentry, MAY_TRUNC|MAY_OWNER_OVERRIDE); | 334 | err = nfsd_permission(rqstp, fhp->fh_export, dentry, |
335 | NFSD_MAY_TRUNC|NFSD_MAY_OWNER_OVERRIDE); | ||
335 | if (err) | 336 | if (err) |
336 | goto out; | 337 | goto out; |
337 | } | 338 | } |
@@ -462,7 +463,7 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
462 | unsigned int flags = 0; | 463 | unsigned int flags = 0; |
463 | 464 | ||
464 | /* Get inode */ | 465 | /* Get inode */ |
465 | error = fh_verify(rqstp, fhp, 0 /* S_IFREG */, MAY_SATTR); | 466 | error = fh_verify(rqstp, fhp, 0 /* S_IFREG */, NFSD_MAY_SATTR); |
466 | if (error) | 467 | if (error) |
467 | return error; | 468 | return error; |
468 | 469 | ||
@@ -563,20 +564,20 @@ struct accessmap { | |||
563 | int how; | 564 | int how; |
564 | }; | 565 | }; |
565 | static struct accessmap nfs3_regaccess[] = { | 566 | static struct accessmap nfs3_regaccess[] = { |
566 | { NFS3_ACCESS_READ, MAY_READ }, | 567 | { NFS3_ACCESS_READ, NFSD_MAY_READ }, |
567 | { NFS3_ACCESS_EXECUTE, MAY_EXEC }, | 568 | { NFS3_ACCESS_EXECUTE, NFSD_MAY_EXEC }, |
568 | { NFS3_ACCESS_MODIFY, MAY_WRITE|MAY_TRUNC }, | 569 | { NFS3_ACCESS_MODIFY, NFSD_MAY_WRITE|NFSD_MAY_TRUNC }, |
569 | { NFS3_ACCESS_EXTEND, MAY_WRITE }, | 570 | { NFS3_ACCESS_EXTEND, NFSD_MAY_WRITE }, |
570 | 571 | ||
571 | { 0, 0 } | 572 | { 0, 0 } |
572 | }; | 573 | }; |
573 | 574 | ||
574 | static struct accessmap nfs3_diraccess[] = { | 575 | static struct accessmap nfs3_diraccess[] = { |
575 | { NFS3_ACCESS_READ, MAY_READ }, | 576 | { NFS3_ACCESS_READ, NFSD_MAY_READ }, |
576 | { NFS3_ACCESS_LOOKUP, MAY_EXEC }, | 577 | { NFS3_ACCESS_LOOKUP, NFSD_MAY_EXEC }, |
577 | { NFS3_ACCESS_MODIFY, MAY_EXEC|MAY_WRITE|MAY_TRUNC }, | 578 | { NFS3_ACCESS_MODIFY, NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC}, |
578 | { NFS3_ACCESS_EXTEND, MAY_EXEC|MAY_WRITE }, | 579 | { NFS3_ACCESS_EXTEND, NFSD_MAY_EXEC|NFSD_MAY_WRITE }, |
579 | { NFS3_ACCESS_DELETE, MAY_REMOVE }, | 580 | { NFS3_ACCESS_DELETE, NFSD_MAY_REMOVE }, |
580 | 581 | ||
581 | { 0, 0 } | 582 | { 0, 0 } |
582 | }; | 583 | }; |
@@ -589,10 +590,10 @@ static struct accessmap nfs3_anyaccess[] = { | |||
589 | * mainly at mode bits, and we make sure to ignore read-only | 590 | * mainly at mode bits, and we make sure to ignore read-only |
590 | * filesystem checks | 591 | * filesystem checks |
591 | */ | 592 | */ |
592 | { NFS3_ACCESS_READ, MAY_READ }, | 593 | { NFS3_ACCESS_READ, NFSD_MAY_READ }, |
593 | { NFS3_ACCESS_EXECUTE, MAY_EXEC }, | 594 | { NFS3_ACCESS_EXECUTE, NFSD_MAY_EXEC }, |
594 | { NFS3_ACCESS_MODIFY, MAY_WRITE|MAY_LOCAL_ACCESS }, | 595 | { NFS3_ACCESS_MODIFY, NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS }, |
595 | { NFS3_ACCESS_EXTEND, MAY_WRITE|MAY_LOCAL_ACCESS }, | 596 | { NFS3_ACCESS_EXTEND, NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS }, |
596 | 597 | ||
597 | { 0, 0 } | 598 | { 0, 0 } |
598 | }; | 599 | }; |
@@ -606,7 +607,7 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor | |||
606 | u32 query, result = 0, sresult = 0; | 607 | u32 query, result = 0, sresult = 0; |
607 | __be32 error; | 608 | __be32 error; |
608 | 609 | ||
609 | error = fh_verify(rqstp, fhp, 0, MAY_NOP); | 610 | error = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); |
610 | if (error) | 611 | if (error) |
611 | goto out; | 612 | goto out; |
612 | 613 | ||
@@ -678,7 +679,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
678 | * and (hopefully) checked permission - so allow OWNER_OVERRIDE | 679 | * and (hopefully) checked permission - so allow OWNER_OVERRIDE |
679 | * in case a chmod has now revoked permission. | 680 | * in case a chmod has now revoked permission. |
680 | */ | 681 | */ |
681 | err = fh_verify(rqstp, fhp, type, access | MAY_OWNER_OVERRIDE); | 682 | err = fh_verify(rqstp, fhp, type, access | NFSD_MAY_OWNER_OVERRIDE); |
682 | if (err) | 683 | if (err) |
683 | goto out; | 684 | goto out; |
684 | 685 | ||
@@ -689,7 +690,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
689 | * or any access when mandatory locking enabled | 690 | * or any access when mandatory locking enabled |
690 | */ | 691 | */ |
691 | err = nfserr_perm; | 692 | err = nfserr_perm; |
692 | if (IS_APPEND(inode) && (access & MAY_WRITE)) | 693 | if (IS_APPEND(inode) && (access & NFSD_MAY_WRITE)) |
693 | goto out; | 694 | goto out; |
694 | /* | 695 | /* |
695 | * We must ignore files (but only files) which might have mandatory | 696 | * We must ignore files (but only files) which might have mandatory |
@@ -706,14 +707,14 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
706 | * Check to see if there are any leases on this file. | 707 | * Check to see if there are any leases on this file. |
707 | * This may block while leases are broken. | 708 | * This may block while leases are broken. |
708 | */ | 709 | */ |
709 | host_err = break_lease(inode, O_NONBLOCK | ((access & MAY_WRITE) ? FMODE_WRITE : 0)); | 710 | host_err = break_lease(inode, O_NONBLOCK | ((access & NFSD_MAY_WRITE) ? FMODE_WRITE : 0)); |
710 | if (host_err == -EWOULDBLOCK) | 711 | if (host_err == -EWOULDBLOCK) |
711 | host_err = -ETIMEDOUT; | 712 | host_err = -ETIMEDOUT; |
712 | if (host_err) /* NOMEM or WOULDBLOCK */ | 713 | if (host_err) /* NOMEM or WOULDBLOCK */ |
713 | goto out_nfserr; | 714 | goto out_nfserr; |
714 | 715 | ||
715 | if (access & MAY_WRITE) { | 716 | if (access & NFSD_MAY_WRITE) { |
716 | if (access & MAY_READ) | 717 | if (access & NFSD_MAY_READ) |
717 | flags = O_RDWR|O_LARGEFILE; | 718 | flags = O_RDWR|O_LARGEFILE; |
718 | else | 719 | else |
719 | flags = O_WRONLY|O_LARGEFILE; | 720 | flags = O_WRONLY|O_LARGEFILE; |
@@ -1069,12 +1070,12 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, | |||
1069 | 1070 | ||
1070 | if (file) { | 1071 | if (file) { |
1071 | err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, | 1072 | err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, |
1072 | MAY_READ|MAY_OWNER_OVERRIDE); | 1073 | NFSD_MAY_READ|NFSD_MAY_OWNER_OVERRIDE); |
1073 | if (err) | 1074 | if (err) |
1074 | goto out; | 1075 | goto out; |
1075 | err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count); | 1076 | err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count); |
1076 | } else { | 1077 | } else { |
1077 | err = nfsd_open(rqstp, fhp, S_IFREG, MAY_READ, &file); | 1078 | err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file); |
1078 | if (err) | 1079 | if (err) |
1079 | goto out; | 1080 | goto out; |
1080 | err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count); | 1081 | err = nfsd_vfs_read(rqstp, fhp, file, offset, vec, vlen, count); |
@@ -1098,13 +1099,13 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, | |||
1098 | 1099 | ||
1099 | if (file) { | 1100 | if (file) { |
1100 | err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, | 1101 | err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, |
1101 | MAY_WRITE|MAY_OWNER_OVERRIDE); | 1102 | NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE); |
1102 | if (err) | 1103 | if (err) |
1103 | goto out; | 1104 | goto out; |
1104 | err = nfsd_vfs_write(rqstp, fhp, file, offset, vec, vlen, cnt, | 1105 | err = nfsd_vfs_write(rqstp, fhp, file, offset, vec, vlen, cnt, |
1105 | stablep); | 1106 | stablep); |
1106 | } else { | 1107 | } else { |
1107 | err = nfsd_open(rqstp, fhp, S_IFREG, MAY_WRITE, &file); | 1108 | err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_WRITE, &file); |
1108 | if (err) | 1109 | if (err) |
1109 | goto out; | 1110 | goto out; |
1110 | 1111 | ||
@@ -1136,7 +1137,8 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1136 | if ((u64)count > ~(u64)offset) | 1137 | if ((u64)count > ~(u64)offset) |
1137 | return nfserr_inval; | 1138 | return nfserr_inval; |
1138 | 1139 | ||
1139 | if ((err = nfsd_open(rqstp, fhp, S_IFREG, MAY_WRITE, &file)) != 0) | 1140 | err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_WRITE, &file); |
1141 | if (err) | ||
1140 | return err; | 1142 | return err; |
1141 | if (EX_ISSYNC(fhp->fh_export)) { | 1143 | if (EX_ISSYNC(fhp->fh_export)) { |
1142 | if (file->f_op && file->f_op->fsync) { | 1144 | if (file->f_op && file->f_op->fsync) { |
@@ -1197,7 +1199,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1197 | if (isdotent(fname, flen)) | 1199 | if (isdotent(fname, flen)) |
1198 | goto out; | 1200 | goto out; |
1199 | 1201 | ||
1200 | err = fh_verify(rqstp, fhp, S_IFDIR, MAY_CREATE); | 1202 | err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE); |
1201 | if (err) | 1203 | if (err) |
1202 | goto out; | 1204 | goto out; |
1203 | 1205 | ||
@@ -1248,36 +1250,34 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1248 | iap->ia_mode = 0; | 1250 | iap->ia_mode = 0; |
1249 | iap->ia_mode = (iap->ia_mode & S_IALLUGO) | type; | 1251 | iap->ia_mode = (iap->ia_mode & S_IALLUGO) | type; |
1250 | 1252 | ||
1253 | err = nfserr_inval; | ||
1254 | if (!S_ISREG(type) && !S_ISDIR(type) && !special_file(type)) { | ||
1255 | printk(KERN_WARNING "nfsd: bad file type %o in nfsd_create\n", | ||
1256 | type); | ||
1257 | goto out; | ||
1258 | } | ||
1259 | |||
1260 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1261 | if (host_err) | ||
1262 | goto out_nfserr; | ||
1263 | |||
1251 | /* | 1264 | /* |
1252 | * Get the dir op function pointer. | 1265 | * Get the dir op function pointer. |
1253 | */ | 1266 | */ |
1254 | err = 0; | 1267 | err = 0; |
1255 | switch (type) { | 1268 | switch (type) { |
1256 | case S_IFREG: | 1269 | case S_IFREG: |
1257 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1258 | if (host_err) | ||
1259 | goto out_nfserr; | ||
1260 | host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL); | 1270 | host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL); |
1261 | break; | 1271 | break; |
1262 | case S_IFDIR: | 1272 | case S_IFDIR: |
1263 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1264 | if (host_err) | ||
1265 | goto out_nfserr; | ||
1266 | host_err = vfs_mkdir(dirp, dchild, iap->ia_mode); | 1273 | host_err = vfs_mkdir(dirp, dchild, iap->ia_mode); |
1267 | break; | 1274 | break; |
1268 | case S_IFCHR: | 1275 | case S_IFCHR: |
1269 | case S_IFBLK: | 1276 | case S_IFBLK: |
1270 | case S_IFIFO: | 1277 | case S_IFIFO: |
1271 | case S_IFSOCK: | 1278 | case S_IFSOCK: |
1272 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1273 | if (host_err) | ||
1274 | goto out_nfserr; | ||
1275 | host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev); | 1279 | host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev); |
1276 | break; | 1280 | break; |
1277 | default: | ||
1278 | printk("nfsd: bad file type %o in nfsd_create\n", type); | ||
1279 | host_err = -EINVAL; | ||
1280 | goto out_nfserr; | ||
1281 | } | 1281 | } |
1282 | if (host_err < 0) { | 1282 | if (host_err < 0) { |
1283 | mnt_drop_write(fhp->fh_export->ex_path.mnt); | 1283 | mnt_drop_write(fhp->fh_export->ex_path.mnt); |
@@ -1289,7 +1289,6 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1289 | write_inode_now(dchild->d_inode, 1); | 1289 | write_inode_now(dchild->d_inode, 1); |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | |||
1293 | err2 = nfsd_create_setattr(rqstp, resfhp, iap); | 1292 | err2 = nfsd_create_setattr(rqstp, resfhp, iap); |
1294 | if (err2) | 1293 | if (err2) |
1295 | err = err2; | 1294 | err = err2; |
@@ -1334,7 +1333,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1334 | goto out; | 1333 | goto out; |
1335 | if (!(iap->ia_valid & ATTR_MODE)) | 1334 | if (!(iap->ia_valid & ATTR_MODE)) |
1336 | iap->ia_mode = 0; | 1335 | iap->ia_mode = 0; |
1337 | err = fh_verify(rqstp, fhp, S_IFDIR, MAY_CREATE); | 1336 | err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE); |
1338 | if (err) | 1337 | if (err) |
1339 | goto out; | 1338 | goto out; |
1340 | 1339 | ||
@@ -1471,7 +1470,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) | |||
1471 | __be32 err; | 1470 | __be32 err; |
1472 | int host_err; | 1471 | int host_err; |
1473 | 1472 | ||
1474 | err = fh_verify(rqstp, fhp, S_IFLNK, MAY_NOP); | 1473 | err = fh_verify(rqstp, fhp, S_IFLNK, NFSD_MAY_NOP); |
1475 | if (err) | 1474 | if (err) |
1476 | goto out; | 1475 | goto out; |
1477 | 1476 | ||
@@ -1526,7 +1525,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1526 | if (isdotent(fname, flen)) | 1525 | if (isdotent(fname, flen)) |
1527 | goto out; | 1526 | goto out; |
1528 | 1527 | ||
1529 | err = fh_verify(rqstp, fhp, S_IFDIR, MAY_CREATE); | 1528 | err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE); |
1530 | if (err) | 1529 | if (err) |
1531 | goto out; | 1530 | goto out; |
1532 | fh_lock(fhp); | 1531 | fh_lock(fhp); |
@@ -1591,10 +1590,10 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp, | |||
1591 | __be32 err; | 1590 | __be32 err; |
1592 | int host_err; | 1591 | int host_err; |
1593 | 1592 | ||
1594 | err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_CREATE); | 1593 | err = fh_verify(rqstp, ffhp, S_IFDIR, NFSD_MAY_CREATE); |
1595 | if (err) | 1594 | if (err) |
1596 | goto out; | 1595 | goto out; |
1597 | err = fh_verify(rqstp, tfhp, -S_IFDIR, MAY_NOP); | 1596 | err = fh_verify(rqstp, tfhp, -S_IFDIR, NFSD_MAY_NOP); |
1598 | if (err) | 1597 | if (err) |
1599 | goto out; | 1598 | goto out; |
1600 | 1599 | ||
@@ -1661,10 +1660,10 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen, | |||
1661 | __be32 err; | 1660 | __be32 err; |
1662 | int host_err; | 1661 | int host_err; |
1663 | 1662 | ||
1664 | err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_REMOVE); | 1663 | err = fh_verify(rqstp, ffhp, S_IFDIR, NFSD_MAY_REMOVE); |
1665 | if (err) | 1664 | if (err) |
1666 | goto out; | 1665 | goto out; |
1667 | err = fh_verify(rqstp, tfhp, S_IFDIR, MAY_CREATE); | 1666 | err = fh_verify(rqstp, tfhp, S_IFDIR, NFSD_MAY_CREATE); |
1668 | if (err) | 1667 | if (err) |
1669 | goto out; | 1668 | goto out; |
1670 | 1669 | ||
@@ -1768,7 +1767,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
1768 | err = nfserr_acces; | 1767 | err = nfserr_acces; |
1769 | if (!flen || isdotent(fname, flen)) | 1768 | if (!flen || isdotent(fname, flen)) |
1770 | goto out; | 1769 | goto out; |
1771 | err = fh_verify(rqstp, fhp, S_IFDIR, MAY_REMOVE); | 1770 | err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_REMOVE); |
1772 | if (err) | 1771 | if (err) |
1773 | goto out; | 1772 | goto out; |
1774 | 1773 | ||
@@ -1834,7 +1833,7 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, | |||
1834 | struct file *file; | 1833 | struct file *file; |
1835 | loff_t offset = *offsetp; | 1834 | loff_t offset = *offsetp; |
1836 | 1835 | ||
1837 | err = nfsd_open(rqstp, fhp, S_IFDIR, MAY_READ, &file); | 1836 | err = nfsd_open(rqstp, fhp, S_IFDIR, NFSD_MAY_READ, &file); |
1838 | if (err) | 1837 | if (err) |
1839 | goto out; | 1838 | goto out; |
1840 | 1839 | ||
@@ -1875,7 +1874,7 @@ out: | |||
1875 | __be32 | 1874 | __be32 |
1876 | nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat) | 1875 | nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat) |
1877 | { | 1876 | { |
1878 | __be32 err = fh_verify(rqstp, fhp, 0, MAY_NOP); | 1877 | __be32 err = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); |
1879 | if (!err && vfs_statfs(fhp->fh_dentry,stat)) | 1878 | if (!err && vfs_statfs(fhp->fh_dentry,stat)) |
1880 | err = nfserr_io; | 1879 | err = nfserr_io; |
1881 | return err; | 1880 | return err; |
@@ -1896,18 +1895,18 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
1896 | struct inode *inode = dentry->d_inode; | 1895 | struct inode *inode = dentry->d_inode; |
1897 | int err; | 1896 | int err; |
1898 | 1897 | ||
1899 | if (acc == MAY_NOP) | 1898 | if (acc == NFSD_MAY_NOP) |
1900 | return 0; | 1899 | return 0; |
1901 | #if 0 | 1900 | #if 0 |
1902 | dprintk("nfsd: permission 0x%x%s%s%s%s%s%s%s mode 0%o%s%s%s\n", | 1901 | dprintk("nfsd: permission 0x%x%s%s%s%s%s%s%s mode 0%o%s%s%s\n", |
1903 | acc, | 1902 | acc, |
1904 | (acc & MAY_READ)? " read" : "", | 1903 | (acc & NFSD_MAY_READ)? " read" : "", |
1905 | (acc & MAY_WRITE)? " write" : "", | 1904 | (acc & NFSD_MAY_WRITE)? " write" : "", |
1906 | (acc & MAY_EXEC)? " exec" : "", | 1905 | (acc & NFSD_MAY_EXEC)? " exec" : "", |
1907 | (acc & MAY_SATTR)? " sattr" : "", | 1906 | (acc & NFSD_MAY_SATTR)? " sattr" : "", |
1908 | (acc & MAY_TRUNC)? " trunc" : "", | 1907 | (acc & NFSD_MAY_TRUNC)? " trunc" : "", |
1909 | (acc & MAY_LOCK)? " lock" : "", | 1908 | (acc & NFSD_MAY_LOCK)? " lock" : "", |
1910 | (acc & MAY_OWNER_OVERRIDE)? " owneroverride" : "", | 1909 | (acc & NFSD_MAY_OWNER_OVERRIDE)? " owneroverride" : "", |
1911 | inode->i_mode, | 1910 | inode->i_mode, |
1912 | IS_IMMUTABLE(inode)? " immut" : "", | 1911 | IS_IMMUTABLE(inode)? " immut" : "", |
1913 | IS_APPEND(inode)? " append" : "", | 1912 | IS_APPEND(inode)? " append" : "", |
@@ -1920,18 +1919,18 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
1920 | * system. But if it is IRIX doing check on write-access for a | 1919 | * system. But if it is IRIX doing check on write-access for a |
1921 | * device special file, we ignore rofs. | 1920 | * device special file, we ignore rofs. |
1922 | */ | 1921 | */ |
1923 | if (!(acc & MAY_LOCAL_ACCESS)) | 1922 | if (!(acc & NFSD_MAY_LOCAL_ACCESS)) |
1924 | if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) { | 1923 | if (acc & (NFSD_MAY_WRITE | NFSD_MAY_SATTR | NFSD_MAY_TRUNC)) { |
1925 | if (exp_rdonly(rqstp, exp) || | 1924 | if (exp_rdonly(rqstp, exp) || |
1926 | __mnt_is_readonly(exp->ex_path.mnt)) | 1925 | __mnt_is_readonly(exp->ex_path.mnt)) |
1927 | return nfserr_rofs; | 1926 | return nfserr_rofs; |
1928 | if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode)) | 1927 | if (/* (acc & NFSD_MAY_WRITE) && */ IS_IMMUTABLE(inode)) |
1929 | return nfserr_perm; | 1928 | return nfserr_perm; |
1930 | } | 1929 | } |
1931 | if ((acc & MAY_TRUNC) && IS_APPEND(inode)) | 1930 | if ((acc & NFSD_MAY_TRUNC) && IS_APPEND(inode)) |
1932 | return nfserr_perm; | 1931 | return nfserr_perm; |
1933 | 1932 | ||
1934 | if (acc & MAY_LOCK) { | 1933 | if (acc & NFSD_MAY_LOCK) { |
1935 | /* If we cannot rely on authentication in NLM requests, | 1934 | /* If we cannot rely on authentication in NLM requests, |
1936 | * just allow locks, otherwise require read permission, or | 1935 | * just allow locks, otherwise require read permission, or |
1937 | * ownership | 1936 | * ownership |
@@ -1939,7 +1938,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
1939 | if (exp->ex_flags & NFSEXP_NOAUTHNLM) | 1938 | if (exp->ex_flags & NFSEXP_NOAUTHNLM) |
1940 | return 0; | 1939 | return 0; |
1941 | else | 1940 | else |
1942 | acc = MAY_READ | MAY_OWNER_OVERRIDE; | 1941 | acc = NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE; |
1943 | } | 1942 | } |
1944 | /* | 1943 | /* |
1945 | * The file owner always gets access permission for accesses that | 1944 | * The file owner always gets access permission for accesses that |
@@ -1955,15 +1954,16 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
1955 | * We must trust the client to do permission checking - using "ACCESS" | 1954 | * We must trust the client to do permission checking - using "ACCESS" |
1956 | * with NFSv3. | 1955 | * with NFSv3. |
1957 | */ | 1956 | */ |
1958 | if ((acc & MAY_OWNER_OVERRIDE) && | 1957 | if ((acc & NFSD_MAY_OWNER_OVERRIDE) && |
1959 | inode->i_uid == current->fsuid) | 1958 | inode->i_uid == current->fsuid) |
1960 | return 0; | 1959 | return 0; |
1961 | 1960 | ||
1961 | /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ | ||
1962 | err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC), NULL); | 1962 | err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC), NULL); |
1963 | 1963 | ||
1964 | /* Allow read access to binaries even when mode 111 */ | 1964 | /* Allow read access to binaries even when mode 111 */ |
1965 | if (err == -EACCES && S_ISREG(inode->i_mode) && | 1965 | if (err == -EACCES && S_ISREG(inode->i_mode) && |
1966 | acc == (MAY_READ | MAY_OWNER_OVERRIDE)) | 1966 | acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE)) |
1967 | err = permission(inode, MAY_EXEC, NULL); | 1967 | err = permission(inode, MAY_EXEC, NULL); |
1968 | 1968 | ||
1969 | return err? nfserrno(err) : 0; | 1969 | return err? nfserrno(err) : 0; |
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 17964c0505a9..1db080135c6d 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -174,10 +174,17 @@ static int ocfs2_get_block(struct inode *inode, sector_t iblock, | |||
174 | * need to use BH_New is when we're extending i_size on a file | 174 | * need to use BH_New is when we're extending i_size on a file |
175 | * system which doesn't support holes, in which case BH_New | 175 | * system which doesn't support holes, in which case BH_New |
176 | * allows block_prepare_write() to zero. | 176 | * allows block_prepare_write() to zero. |
177 | * | ||
178 | * If we see this on a sparse file system, then a truncate has | ||
179 | * raced us and removed the cluster. In this case, we clear | ||
180 | * the buffers dirty and uptodate bits and let the buffer code | ||
181 | * ignore it as a hole. | ||
177 | */ | 182 | */ |
178 | mlog_bug_on_msg(create && p_blkno == 0 && ocfs2_sparse_alloc(osb), | 183 | if (create && p_blkno == 0 && ocfs2_sparse_alloc(osb)) { |
179 | "ino %lu, iblock %llu\n", inode->i_ino, | 184 | clear_buffer_dirty(bh_result); |
180 | (unsigned long long)iblock); | 185 | clear_buffer_uptodate(bh_result); |
186 | goto bail; | ||
187 | } | ||
181 | 188 | ||
182 | /* Treat the unwritten extent as a hole for zeroing purposes. */ | 189 | /* Treat the unwritten extent as a hole for zeroing purposes. */ |
183 | if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) | 190 | if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) |
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index f02ccb34604d..7dce1612553e 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -1493,24 +1493,18 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g | |||
1493 | const char *name) | 1493 | const char *name) |
1494 | { | 1494 | { |
1495 | struct o2hb_region *reg = NULL; | 1495 | struct o2hb_region *reg = NULL; |
1496 | struct config_item *ret = NULL; | ||
1497 | 1496 | ||
1498 | reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); | 1497 | reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); |
1499 | if (reg == NULL) | 1498 | if (reg == NULL) |
1500 | goto out; /* ENOMEM */ | 1499 | return ERR_PTR(-ENOMEM); |
1501 | 1500 | ||
1502 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); | 1501 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); |
1503 | 1502 | ||
1504 | ret = ®->hr_item; | ||
1505 | |||
1506 | spin_lock(&o2hb_live_lock); | 1503 | spin_lock(&o2hb_live_lock); |
1507 | list_add_tail(®->hr_all_item, &o2hb_all_regions); | 1504 | list_add_tail(®->hr_all_item, &o2hb_all_regions); |
1508 | spin_unlock(&o2hb_live_lock); | 1505 | spin_unlock(&o2hb_live_lock); |
1509 | out: | ||
1510 | if (ret == NULL) | ||
1511 | kfree(reg); | ||
1512 | 1506 | ||
1513 | return ret; | 1507 | return ®->hr_item; |
1514 | } | 1508 | } |
1515 | 1509 | ||
1516 | static void o2hb_heartbeat_group_drop_item(struct config_group *group, | 1510 | static void o2hb_heartbeat_group_drop_item(struct config_group *group, |
diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index 7bf3c0ea7bd9..d8bfa0eb41b2 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c | |||
@@ -146,8 +146,10 @@ static int nst_seq_show(struct seq_file *seq, void *v) | |||
146 | nst->st_task->comm, nst->st_node, | 146 | nst->st_task->comm, nst->st_node, |
147 | nst->st_sc, nst->st_id, nst->st_msg_type, | 147 | nst->st_sc, nst->st_id, nst->st_msg_type, |
148 | nst->st_msg_key, | 148 | nst->st_msg_key, |
149 | nst->st_sock_time.tv_sec, nst->st_sock_time.tv_usec, | 149 | nst->st_sock_time.tv_sec, |
150 | nst->st_send_time.tv_sec, nst->st_send_time.tv_usec, | 150 | (unsigned long)nst->st_sock_time.tv_usec, |
151 | nst->st_send_time.tv_sec, | ||
152 | (unsigned long)nst->st_send_time.tv_usec, | ||
151 | nst->st_status_time.tv_sec, | 153 | nst->st_status_time.tv_sec, |
152 | nst->st_status_time.tv_usec); | 154 | nst->st_status_time.tv_usec); |
153 | } | 155 | } |
@@ -274,7 +276,7 @@ static void *sc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
274 | return sc; /* unused, just needs to be null when done */ | 276 | return sc; /* unused, just needs to be null when done */ |
275 | } | 277 | } |
276 | 278 | ||
277 | #define TV_SEC_USEC(TV) TV.tv_sec, TV.tv_usec | 279 | #define TV_SEC_USEC(TV) TV.tv_sec, (unsigned long)TV.tv_usec |
278 | 280 | ||
279 | static int sc_seq_show(struct seq_file *seq, void *v) | 281 | static int sc_seq_show(struct seq_file *seq, void *v) |
280 | { | 282 | { |
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index cfdb08b484ed..816a3f61330c 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -648,26 +648,19 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group, | |||
648 | const char *name) | 648 | const char *name) |
649 | { | 649 | { |
650 | struct o2nm_node *node = NULL; | 650 | struct o2nm_node *node = NULL; |
651 | struct config_item *ret = NULL; | ||
652 | 651 | ||
653 | if (strlen(name) > O2NM_MAX_NAME_LEN) | 652 | if (strlen(name) > O2NM_MAX_NAME_LEN) |
654 | goto out; /* ENAMETOOLONG */ | 653 | return ERR_PTR(-ENAMETOOLONG); |
655 | 654 | ||
656 | node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); | 655 | node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); |
657 | if (node == NULL) | 656 | if (node == NULL) |
658 | goto out; /* ENOMEM */ | 657 | return ERR_PTR(-ENOMEM); |
659 | 658 | ||
660 | strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ | 659 | strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ |
661 | config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); | 660 | config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); |
662 | spin_lock_init(&node->nd_lock); | 661 | spin_lock_init(&node->nd_lock); |
663 | 662 | ||
664 | ret = &node->nd_item; | 663 | return &node->nd_item; |
665 | |||
666 | out: | ||
667 | if (ret == NULL) | ||
668 | kfree(node); | ||
669 | |||
670 | return ret; | ||
671 | } | 664 | } |
672 | 665 | ||
673 | static void o2nm_node_group_drop_item(struct config_group *group, | 666 | static void o2nm_node_group_drop_item(struct config_group *group, |
@@ -762,7 +755,7 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g | |||
762 | /* this runs under the parent dir's i_mutex; there can be only | 755 | /* this runs under the parent dir's i_mutex; there can be only |
763 | * one caller in here at a time */ | 756 | * one caller in here at a time */ |
764 | if (o2nm_single_cluster) | 757 | if (o2nm_single_cluster) |
765 | goto out; /* ENOSPC */ | 758 | return ERR_PTR(-ENOSPC); |
766 | 759 | ||
767 | cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); | 760 | cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); |
768 | ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); | 761 | ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); |
@@ -795,6 +788,7 @@ out: | |||
795 | kfree(ns); | 788 | kfree(ns); |
796 | o2hb_free_hb_set(o2hb_group); | 789 | o2hb_free_hb_set(o2hb_group); |
797 | kfree(defs); | 790 | kfree(defs); |
791 | ret = ERR_PTR(-ENOMEM); | ||
798 | } | 792 | } |
799 | 793 | ||
800 | return ret; | 794 | return ret; |
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 80e20d9f2780..eae3d643a5e4 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/pagemap.h> | 31 | #include <linux/pagemap.h> |
32 | #include <linux/debugfs.h> | 32 | #include <linux/debugfs.h> |
33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
34 | #include <linux/time.h> | ||
34 | 35 | ||
35 | #define MLOG_MASK_PREFIX ML_DLM_GLUE | 36 | #define MLOG_MASK_PREFIX ML_DLM_GLUE |
36 | #include <cluster/masklog.h> | 37 | #include <cluster/masklog.h> |
@@ -59,6 +60,9 @@ struct ocfs2_mask_waiter { | |||
59 | struct completion mw_complete; | 60 | struct completion mw_complete; |
60 | unsigned long mw_mask; | 61 | unsigned long mw_mask; |
61 | unsigned long mw_goal; | 62 | unsigned long mw_goal; |
63 | #ifdef CONFIG_OCFS2_FS_STATS | ||
64 | unsigned long long mw_lock_start; | ||
65 | #endif | ||
62 | }; | 66 | }; |
63 | 67 | ||
64 | static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres); | 68 | static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres); |
@@ -366,6 +370,75 @@ static void ocfs2_remove_lockres_tracking(struct ocfs2_lock_res *res) | |||
366 | spin_unlock(&ocfs2_dlm_tracking_lock); | 370 | spin_unlock(&ocfs2_dlm_tracking_lock); |
367 | } | 371 | } |
368 | 372 | ||
373 | #ifdef CONFIG_OCFS2_FS_STATS | ||
374 | static void ocfs2_init_lock_stats(struct ocfs2_lock_res *res) | ||
375 | { | ||
376 | res->l_lock_num_prmode = 0; | ||
377 | res->l_lock_num_prmode_failed = 0; | ||
378 | res->l_lock_total_prmode = 0; | ||
379 | res->l_lock_max_prmode = 0; | ||
380 | res->l_lock_num_exmode = 0; | ||
381 | res->l_lock_num_exmode_failed = 0; | ||
382 | res->l_lock_total_exmode = 0; | ||
383 | res->l_lock_max_exmode = 0; | ||
384 | res->l_lock_refresh = 0; | ||
385 | } | ||
386 | |||
387 | static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, | ||
388 | struct ocfs2_mask_waiter *mw, int ret) | ||
389 | { | ||
390 | unsigned long long *num, *sum; | ||
391 | unsigned int *max, *failed; | ||
392 | struct timespec ts = current_kernel_time(); | ||
393 | unsigned long long time = timespec_to_ns(&ts) - mw->mw_lock_start; | ||
394 | |||
395 | if (level == LKM_PRMODE) { | ||
396 | num = &res->l_lock_num_prmode; | ||
397 | sum = &res->l_lock_total_prmode; | ||
398 | max = &res->l_lock_max_prmode; | ||
399 | failed = &res->l_lock_num_prmode_failed; | ||
400 | } else if (level == LKM_EXMODE) { | ||
401 | num = &res->l_lock_num_exmode; | ||
402 | sum = &res->l_lock_total_exmode; | ||
403 | max = &res->l_lock_max_exmode; | ||
404 | failed = &res->l_lock_num_exmode_failed; | ||
405 | } else | ||
406 | return; | ||
407 | |||
408 | (*num)++; | ||
409 | (*sum) += time; | ||
410 | if (time > *max) | ||
411 | *max = time; | ||
412 | if (ret) | ||
413 | (*failed)++; | ||
414 | } | ||
415 | |||
416 | static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) | ||
417 | { | ||
418 | lockres->l_lock_refresh++; | ||
419 | } | ||
420 | |||
421 | static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw) | ||
422 | { | ||
423 | struct timespec ts = current_kernel_time(); | ||
424 | mw->mw_lock_start = timespec_to_ns(&ts); | ||
425 | } | ||
426 | #else | ||
427 | static inline void ocfs2_init_lock_stats(struct ocfs2_lock_res *res) | ||
428 | { | ||
429 | } | ||
430 | static inline void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, | ||
431 | int level, struct ocfs2_mask_waiter *mw, int ret) | ||
432 | { | ||
433 | } | ||
434 | static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) | ||
435 | { | ||
436 | } | ||
437 | static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw) | ||
438 | { | ||
439 | } | ||
440 | #endif | ||
441 | |||
369 | static void ocfs2_lock_res_init_common(struct ocfs2_super *osb, | 442 | static void ocfs2_lock_res_init_common(struct ocfs2_super *osb, |
370 | struct ocfs2_lock_res *res, | 443 | struct ocfs2_lock_res *res, |
371 | enum ocfs2_lock_type type, | 444 | enum ocfs2_lock_type type, |
@@ -385,6 +458,8 @@ static void ocfs2_lock_res_init_common(struct ocfs2_super *osb, | |||
385 | res->l_flags = OCFS2_LOCK_INITIALIZED; | 458 | res->l_flags = OCFS2_LOCK_INITIALIZED; |
386 | 459 | ||
387 | ocfs2_add_lockres_tracking(res, osb->osb_dlm_debug); | 460 | ocfs2_add_lockres_tracking(res, osb->osb_dlm_debug); |
461 | |||
462 | ocfs2_init_lock_stats(res); | ||
388 | } | 463 | } |
389 | 464 | ||
390 | void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res) | 465 | void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res) |
@@ -1048,6 +1123,7 @@ static void ocfs2_init_mask_waiter(struct ocfs2_mask_waiter *mw) | |||
1048 | { | 1123 | { |
1049 | INIT_LIST_HEAD(&mw->mw_item); | 1124 | INIT_LIST_HEAD(&mw->mw_item); |
1050 | init_completion(&mw->mw_complete); | 1125 | init_completion(&mw->mw_complete); |
1126 | ocfs2_init_start_time(mw); | ||
1051 | } | 1127 | } |
1052 | 1128 | ||
1053 | static int ocfs2_wait_for_mask(struct ocfs2_mask_waiter *mw) | 1129 | static int ocfs2_wait_for_mask(struct ocfs2_mask_waiter *mw) |
@@ -1254,6 +1330,7 @@ out: | |||
1254 | goto again; | 1330 | goto again; |
1255 | mlog_errno(ret); | 1331 | mlog_errno(ret); |
1256 | } | 1332 | } |
1333 | ocfs2_update_lock_stats(lockres, level, &mw, ret); | ||
1257 | 1334 | ||
1258 | mlog_exit(ret); | 1335 | mlog_exit(ret); |
1259 | return ret; | 1336 | return ret; |
@@ -1983,6 +2060,7 @@ static int ocfs2_inode_lock_update(struct inode *inode, | |||
1983 | le32_to_cpu(fe->i_flags)); | 2060 | le32_to_cpu(fe->i_flags)); |
1984 | 2061 | ||
1985 | ocfs2_refresh_inode(inode, fe); | 2062 | ocfs2_refresh_inode(inode, fe); |
2063 | ocfs2_track_lock_refresh(lockres); | ||
1986 | } | 2064 | } |
1987 | 2065 | ||
1988 | status = 0; | 2066 | status = 0; |
@@ -2267,6 +2345,7 @@ int ocfs2_super_lock(struct ocfs2_super *osb, | |||
2267 | 2345 | ||
2268 | if (status < 0) | 2346 | if (status < 0) |
2269 | mlog_errno(status); | 2347 | mlog_errno(status); |
2348 | ocfs2_track_lock_refresh(lockres); | ||
2270 | } | 2349 | } |
2271 | bail: | 2350 | bail: |
2272 | mlog_exit(status); | 2351 | mlog_exit(status); |
@@ -2461,7 +2540,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) | |||
2461 | } | 2540 | } |
2462 | 2541 | ||
2463 | /* So that debugfs.ocfs2 can determine which format is being used */ | 2542 | /* So that debugfs.ocfs2 can determine which format is being used */ |
2464 | #define OCFS2_DLM_DEBUG_STR_VERSION 1 | 2543 | #define OCFS2_DLM_DEBUG_STR_VERSION 2 |
2465 | static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) | 2544 | static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) |
2466 | { | 2545 | { |
2467 | int i; | 2546 | int i; |
@@ -2502,6 +2581,47 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) | |||
2502 | for(i = 0; i < DLM_LVB_LEN; i++) | 2581 | for(i = 0; i < DLM_LVB_LEN; i++) |
2503 | seq_printf(m, "0x%x\t", lvb[i]); | 2582 | seq_printf(m, "0x%x\t", lvb[i]); |
2504 | 2583 | ||
2584 | #ifdef CONFIG_OCFS2_FS_STATS | ||
2585 | # define lock_num_prmode(_l) (_l)->l_lock_num_prmode | ||
2586 | # define lock_num_exmode(_l) (_l)->l_lock_num_exmode | ||
2587 | # define lock_num_prmode_failed(_l) (_l)->l_lock_num_prmode_failed | ||
2588 | # define lock_num_exmode_failed(_l) (_l)->l_lock_num_exmode_failed | ||
2589 | # define lock_total_prmode(_l) (_l)->l_lock_total_prmode | ||
2590 | # define lock_total_exmode(_l) (_l)->l_lock_total_exmode | ||
2591 | # define lock_max_prmode(_l) (_l)->l_lock_max_prmode | ||
2592 | # define lock_max_exmode(_l) (_l)->l_lock_max_exmode | ||
2593 | # define lock_refresh(_l) (_l)->l_lock_refresh | ||
2594 | #else | ||
2595 | # define lock_num_prmode(_l) (0ULL) | ||
2596 | # define lock_num_exmode(_l) (0ULL) | ||
2597 | # define lock_num_prmode_failed(_l) (0) | ||
2598 | # define lock_num_exmode_failed(_l) (0) | ||
2599 | # define lock_total_prmode(_l) (0ULL) | ||
2600 | # define lock_total_exmode(_l) (0ULL) | ||
2601 | # define lock_max_prmode(_l) (0) | ||
2602 | # define lock_max_exmode(_l) (0) | ||
2603 | # define lock_refresh(_l) (0) | ||
2604 | #endif | ||
2605 | /* The following seq_print was added in version 2 of this output */ | ||
2606 | seq_printf(m, "%llu\t" | ||
2607 | "%llu\t" | ||
2608 | "%u\t" | ||
2609 | "%u\t" | ||
2610 | "%llu\t" | ||
2611 | "%llu\t" | ||
2612 | "%u\t" | ||
2613 | "%u\t" | ||
2614 | "%u\t", | ||
2615 | lock_num_prmode(lockres), | ||
2616 | lock_num_exmode(lockres), | ||
2617 | lock_num_prmode_failed(lockres), | ||
2618 | lock_num_exmode_failed(lockres), | ||
2619 | lock_total_prmode(lockres), | ||
2620 | lock_total_exmode(lockres), | ||
2621 | lock_max_prmode(lockres), | ||
2622 | lock_max_exmode(lockres), | ||
2623 | lock_refresh(lockres)); | ||
2624 | |||
2505 | /* End the line */ | 2625 | /* End the line */ |
2506 | seq_printf(m, "\n"); | 2626 | seq_printf(m, "\n"); |
2507 | return 0; | 2627 | return 0; |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 57e0d30cde98..e8514e8b6ce8 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2202,7 +2202,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
2202 | 2202 | ||
2203 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); | 2203 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); |
2204 | if (ret == -EINVAL) | 2204 | if (ret == -EINVAL) |
2205 | mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n"); | 2205 | mlog(0, "generic_file_aio_read returned -EINVAL\n"); |
2206 | 2206 | ||
2207 | /* buffered aio wouldn't have proper lock coverage today */ | 2207 | /* buffered aio wouldn't have proper lock coverage today */ |
2208 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); | 2208 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 9698338adc39..a8c19cb3cfdd 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -329,7 +329,7 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks) | |||
329 | 329 | ||
330 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); | 330 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); |
331 | 331 | ||
332 | #ifdef OCFS2_DEBUG_FS | 332 | #ifdef CONFIG_OCFS2_DEBUG_FS |
333 | status = 1; | 333 | status = 1; |
334 | #else | 334 | #else |
335 | status = journal_extend(handle, nblocks); | 335 | status = journal_extend(handle, nblocks); |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index be774bdc8b36..28e492e4ec88 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -498,7 +498,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
498 | 498 | ||
499 | alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; | 499 | alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; |
500 | 500 | ||
501 | #ifdef OCFS2_DEBUG_FS | 501 | #ifdef CONFIG_OCFS2_DEBUG_FS |
502 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) != | 502 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) != |
503 | ocfs2_local_alloc_count_bits(alloc)) { | 503 | ocfs2_local_alloc_count_bits(alloc)) { |
504 | ocfs2_error(osb->sb, "local alloc inode %llu says it has " | 504 | ocfs2_error(osb->sb, "local alloc inode %llu says it has " |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 31692379c170..1cb814be8ef1 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -132,6 +132,18 @@ struct ocfs2_lock_res { | |||
132 | wait_queue_head_t l_event; | 132 | wait_queue_head_t l_event; |
133 | 133 | ||
134 | struct list_head l_debug_list; | 134 | struct list_head l_debug_list; |
135 | |||
136 | #ifdef CONFIG_OCFS2_FS_STATS | ||
137 | unsigned long long l_lock_num_prmode; /* PR acquires */ | ||
138 | unsigned long long l_lock_num_exmode; /* EX acquires */ | ||
139 | unsigned int l_lock_num_prmode_failed; /* Failed PR gets */ | ||
140 | unsigned int l_lock_num_exmode_failed; /* Failed EX gets */ | ||
141 | unsigned long long l_lock_total_prmode; /* Tot wait for PR */ | ||
142 | unsigned long long l_lock_total_exmode; /* Tot wait for EX */ | ||
143 | unsigned int l_lock_max_prmode; /* Max wait for PR */ | ||
144 | unsigned int l_lock_max_exmode; /* Max wait for EX */ | ||
145 | unsigned int l_lock_refresh; /* Disk refreshes */ | ||
146 | #endif | ||
135 | }; | 147 | }; |
136 | 148 | ||
137 | struct ocfs2_dlm_debug { | 149 | struct ocfs2_dlm_debug { |
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 52c426665154..3f1945177629 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -901,7 +901,7 @@ static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, | |||
901 | * list has a copy per slot. | 901 | * list has a copy per slot. |
902 | */ | 902 | */ |
903 | if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) | 903 | if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) |
904 | chars = snprintf(buf, len, | 904 | chars = snprintf(buf, len, "%s", |
905 | ocfs2_system_inodes[type].si_name); | 905 | ocfs2_system_inodes[type].si_name); |
906 | else | 906 | else |
907 | chars = snprintf(buf, len, | 907 | chars = snprintf(buf, len, |
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index bd7e0f3acfc7..353fc35c6748 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c | |||
@@ -550,26 +550,17 @@ static ssize_t ocfs2_control_read(struct file *file, | |||
550 | size_t count, | 550 | size_t count, |
551 | loff_t *ppos) | 551 | loff_t *ppos) |
552 | { | 552 | { |
553 | char *proto_string = OCFS2_CONTROL_PROTO; | 553 | ssize_t ret; |
554 | size_t to_write = 0; | ||
555 | |||
556 | if (*ppos >= OCFS2_CONTROL_PROTO_LEN) | ||
557 | return 0; | ||
558 | |||
559 | to_write = OCFS2_CONTROL_PROTO_LEN - *ppos; | ||
560 | if (to_write > count) | ||
561 | to_write = count; | ||
562 | if (copy_to_user(buf, proto_string + *ppos, to_write)) | ||
563 | return -EFAULT; | ||
564 | 554 | ||
565 | *ppos += to_write; | 555 | ret = simple_read_from_buffer(buf, count, ppos, |
556 | OCFS2_CONTROL_PROTO, OCFS2_CONTROL_PROTO_LEN); | ||
566 | 557 | ||
567 | /* Have we read the whole protocol list? */ | 558 | /* Have we read the whole protocol list? */ |
568 | if (*ppos >= OCFS2_CONTROL_PROTO_LEN) | 559 | if (ret > 0 && *ppos >= OCFS2_CONTROL_PROTO_LEN) |
569 | ocfs2_control_set_handshake_state(file, | 560 | ocfs2_control_set_handshake_state(file, |
570 | OCFS2_CONTROL_HANDSHAKE_READ); | 561 | OCFS2_CONTROL_HANDSHAKE_READ); |
571 | 562 | ||
572 | return to_write; | 563 | return ret; |
573 | } | 564 | } |
574 | 565 | ||
575 | static int ocfs2_control_release(struct inode *inode, struct file *file) | 566 | static int ocfs2_control_release(struct inode *inode, struct file *file) |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index df63ba20ae90..ccecfe5094fa 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -1703,7 +1703,11 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
1703 | local = ocfs2_mount_local(osb); | 1703 | local = ocfs2_mount_local(osb); |
1704 | 1704 | ||
1705 | /* will play back anything left in the journal. */ | 1705 | /* will play back anything left in the journal. */ |
1706 | ocfs2_journal_load(osb->journal, local); | 1706 | status = ocfs2_journal_load(osb->journal, local); |
1707 | if (status < 0) { | ||
1708 | mlog(ML_ERROR, "ocfs2 journal load failed! %d\n", status); | ||
1709 | goto finally; | ||
1710 | } | ||
1707 | 1711 | ||
1708 | if (dirty) { | 1712 | if (dirty) { |
1709 | /* recover my local alloc if we didn't unmount cleanly. */ | 1713 | /* recover my local alloc if we didn't unmount cleanly. */ |
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 83f357b30d71..b224a28e0c15 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -51,6 +51,30 @@ int seq_open_net(struct inode *ino, struct file *f, | |||
51 | } | 51 | } |
52 | EXPORT_SYMBOL_GPL(seq_open_net); | 52 | EXPORT_SYMBOL_GPL(seq_open_net); |
53 | 53 | ||
54 | int single_open_net(struct inode *inode, struct file *file, | ||
55 | int (*show)(struct seq_file *, void *)) | ||
56 | { | ||
57 | int err; | ||
58 | struct net *net; | ||
59 | |||
60 | err = -ENXIO; | ||
61 | net = get_proc_net(inode); | ||
62 | if (net == NULL) | ||
63 | goto err_net; | ||
64 | |||
65 | err = single_open(file, show, net); | ||
66 | if (err < 0) | ||
67 | goto err_open; | ||
68 | |||
69 | return 0; | ||
70 | |||
71 | err_open: | ||
72 | put_net(net); | ||
73 | err_net: | ||
74 | return err; | ||
75 | } | ||
76 | EXPORT_SYMBOL_GPL(single_open_net); | ||
77 | |||
54 | int seq_release_net(struct inode *ino, struct file *f) | 78 | int seq_release_net(struct inode *ino, struct file *f) |
55 | { | 79 | { |
56 | struct seq_file *seq; | 80 | struct seq_file *seq; |
@@ -63,6 +87,14 @@ int seq_release_net(struct inode *ino, struct file *f) | |||
63 | } | 87 | } |
64 | EXPORT_SYMBOL_GPL(seq_release_net); | 88 | EXPORT_SYMBOL_GPL(seq_release_net); |
65 | 89 | ||
90 | int single_release_net(struct inode *ino, struct file *f) | ||
91 | { | ||
92 | struct seq_file *seq = f->private_data; | ||
93 | put_net(seq->private); | ||
94 | return single_release(ino, f); | ||
95 | } | ||
96 | EXPORT_SYMBOL_GPL(single_release_net); | ||
97 | |||
66 | static struct net *get_proc_task_net(struct inode *dir) | 98 | static struct net *get_proc_task_net(struct inode *dir) |
67 | { | 99 | { |
68 | struct task_struct *task; | 100 | struct task_struct *task; |
diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c index 21f490f5d65c..d153946d6d15 100644 --- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c | |||
@@ -136,54 +136,6 @@ static const struct file_operations proc_tty_drivers_operations = { | |||
136 | .release = seq_release, | 136 | .release = seq_release, |
137 | }; | 137 | }; |
138 | 138 | ||
139 | static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) | ||
140 | { | ||
141 | return (*pos < NR_LDISCS) ? pos : NULL; | ||
142 | } | ||
143 | |||
144 | static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos) | ||
145 | { | ||
146 | (*pos)++; | ||
147 | return (*pos < NR_LDISCS) ? pos : NULL; | ||
148 | } | ||
149 | |||
150 | static void tty_ldiscs_seq_stop(struct seq_file *m, void *v) | ||
151 | { | ||
152 | } | ||
153 | |||
154 | static int tty_ldiscs_seq_show(struct seq_file *m, void *v) | ||
155 | { | ||
156 | int i = *(loff_t *)v; | ||
157 | struct tty_ldisc *ld; | ||
158 | |||
159 | ld = tty_ldisc_get(i); | ||
160 | if (ld == NULL) | ||
161 | return 0; | ||
162 | seq_printf(m, "%-10s %2d\n", ld->name ? ld->name : "???", i); | ||
163 | tty_ldisc_put(i); | ||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | static const struct seq_operations tty_ldiscs_seq_ops = { | ||
168 | .start = tty_ldiscs_seq_start, | ||
169 | .next = tty_ldiscs_seq_next, | ||
170 | .stop = tty_ldiscs_seq_stop, | ||
171 | .show = tty_ldiscs_seq_show, | ||
172 | }; | ||
173 | |||
174 | static int proc_tty_ldiscs_open(struct inode *inode, struct file *file) | ||
175 | { | ||
176 | return seq_open(file, &tty_ldiscs_seq_ops); | ||
177 | } | ||
178 | |||
179 | static const struct file_operations tty_ldiscs_proc_fops = { | ||
180 | .owner = THIS_MODULE, | ||
181 | .open = proc_tty_ldiscs_open, | ||
182 | .read = seq_read, | ||
183 | .llseek = seq_lseek, | ||
184 | .release = seq_release, | ||
185 | }; | ||
186 | |||
187 | /* | 139 | /* |
188 | * This function is called by tty_register_driver() to handle | 140 | * This function is called by tty_register_driver() to handle |
189 | * registering the driver's /proc handler into /proc/tty/driver/<foo> | 141 | * registering the driver's /proc handler into /proc/tty/driver/<foo> |