diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-30 20:10:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-30 20:10:26 -0400 |
commit | f927318840745095cc7003f1564ca4b87655745d (patch) | |
tree | 0602e3688ff43ac32f7f6f7e2a6e554072f2b0ee | |
parent | 522d6d38f83a3809d26db7e24fafc56404693606 (diff) | |
parent | 367156d9a87b21b5232dd93107c5fc61b09ba2ef (diff) |
Merge tag 'nfs-for-3.12-4' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client bugfixes from Trond Myklebust:
- Stable fix for Oopses in the pNFS files layout driver
- Fix a regression when doing a non-exclusive file create on NFSv4.x
- NFSv4.1 security negotiation fixes when looking up the root
filesystem
- Fix a memory ordering issue in the pNFS files layout driver
* tag 'nfs-for-3.12-4' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
NFS: Give "flavor" an initial value to fix a compile warning
NFSv4.1: try SECINFO_NO_NAME flavs until one works
NFSv4.1: Ensure memory ordering between nfs4_ds_connect and nfs4_fl_prepare_ds
NFSv4.1: nfs4_fl_prepare_ds - fix bugs when the connect attempt fails
NFSv4: Honour the 'opened' parameter in the atomic_open() filesystem method
-rw-r--r-- | fs/nfs/dir.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4file.c | 3 | ||||
-rw-r--r-- | fs/nfs/nfs4filelayoutdev.c | 20 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 58 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 3 |
5 files changed, 63 insertions, 23 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 854a8f05a610..02b0df769e2d 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1458,7 +1458,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, | |||
1458 | 1458 | ||
1459 | trace_nfs_atomic_open_enter(dir, ctx, open_flags); | 1459 | trace_nfs_atomic_open_enter(dir, ctx, open_flags); |
1460 | nfs_block_sillyrename(dentry->d_parent); | 1460 | nfs_block_sillyrename(dentry->d_parent); |
1461 | inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr); | 1461 | inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr, opened); |
1462 | nfs_unblock_sillyrename(dentry->d_parent); | 1462 | nfs_unblock_sillyrename(dentry->d_parent); |
1463 | if (IS_ERR(inode)) { | 1463 | if (IS_ERR(inode)) { |
1464 | err = PTR_ERR(inode); | 1464 | err = PTR_ERR(inode); |
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index e5b804dd944c..77efaf15ec90 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c | |||
@@ -19,6 +19,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) | |||
19 | struct inode *dir; | 19 | struct inode *dir; |
20 | unsigned openflags = filp->f_flags; | 20 | unsigned openflags = filp->f_flags; |
21 | struct iattr attr; | 21 | struct iattr attr; |
22 | int opened = 0; | ||
22 | int err; | 23 | int err; |
23 | 24 | ||
24 | /* | 25 | /* |
@@ -55,7 +56,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) | |||
55 | nfs_wb_all(inode); | 56 | nfs_wb_all(inode); |
56 | } | 57 | } |
57 | 58 | ||
58 | inode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr); | 59 | inode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr, &opened); |
59 | if (IS_ERR(inode)) { | 60 | if (IS_ERR(inode)) { |
60 | err = PTR_ERR(inode); | 61 | err = PTR_ERR(inode); |
61 | switch (err) { | 62 | switch (err) { |
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index 95604f64cab8..c7c295e556ed 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c | |||
@@ -185,6 +185,7 @@ nfs4_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds) | |||
185 | if (status) | 185 | if (status) |
186 | goto out_put; | 186 | goto out_put; |
187 | 187 | ||
188 | smp_wmb(); | ||
188 | ds->ds_clp = clp; | 189 | ds->ds_clp = clp; |
189 | dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr); | 190 | dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr); |
190 | out: | 191 | out: |
@@ -801,34 +802,35 @@ nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx) | |||
801 | struct nfs4_file_layout_dsaddr *dsaddr = FILELAYOUT_LSEG(lseg)->dsaddr; | 802 | struct nfs4_file_layout_dsaddr *dsaddr = FILELAYOUT_LSEG(lseg)->dsaddr; |
802 | struct nfs4_pnfs_ds *ds = dsaddr->ds_list[ds_idx]; | 803 | struct nfs4_pnfs_ds *ds = dsaddr->ds_list[ds_idx]; |
803 | struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg); | 804 | struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg); |
804 | 805 | struct nfs4_pnfs_ds *ret = ds; | |
805 | if (filelayout_test_devid_unavailable(devid)) | ||
806 | return NULL; | ||
807 | 806 | ||
808 | if (ds == NULL) { | 807 | if (ds == NULL) { |
809 | printk(KERN_ERR "NFS: %s: No data server for offset index %d\n", | 808 | printk(KERN_ERR "NFS: %s: No data server for offset index %d\n", |
810 | __func__, ds_idx); | 809 | __func__, ds_idx); |
811 | filelayout_mark_devid_invalid(devid); | 810 | filelayout_mark_devid_invalid(devid); |
812 | return NULL; | 811 | goto out; |
813 | } | 812 | } |
813 | smp_rmb(); | ||
814 | if (ds->ds_clp) | 814 | if (ds->ds_clp) |
815 | return ds; | 815 | goto out_test_devid; |
816 | 816 | ||
817 | if (test_and_set_bit(NFS4DS_CONNECTING, &ds->ds_state) == 0) { | 817 | if (test_and_set_bit(NFS4DS_CONNECTING, &ds->ds_state) == 0) { |
818 | struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode); | 818 | struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode); |
819 | int err; | 819 | int err; |
820 | 820 | ||
821 | err = nfs4_ds_connect(s, ds); | 821 | err = nfs4_ds_connect(s, ds); |
822 | if (err) { | 822 | if (err) |
823 | nfs4_mark_deviceid_unavailable(devid); | 823 | nfs4_mark_deviceid_unavailable(devid); |
824 | ds = NULL; | ||
825 | } | ||
826 | nfs4_clear_ds_conn_bit(ds); | 824 | nfs4_clear_ds_conn_bit(ds); |
827 | } else { | 825 | } else { |
828 | /* Either ds is connected, or ds is NULL */ | 826 | /* Either ds is connected, or ds is NULL */ |
829 | nfs4_wait_ds_connect(ds); | 827 | nfs4_wait_ds_connect(ds); |
830 | } | 828 | } |
831 | return ds; | 829 | out_test_devid: |
830 | if (filelayout_test_devid_unavailable(devid)) | ||
831 | ret = NULL; | ||
832 | out: | ||
833 | return ret; | ||
832 | } | 834 | } |
833 | 835 | ||
834 | module_param(dataserver_retrans, uint, 0644); | 836 | module_param(dataserver_retrans, uint, 0644); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 989bb9d3074d..d53d6785cba2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -912,6 +912,7 @@ struct nfs4_opendata { | |||
912 | struct iattr attrs; | 912 | struct iattr attrs; |
913 | unsigned long timestamp; | 913 | unsigned long timestamp; |
914 | unsigned int rpc_done : 1; | 914 | unsigned int rpc_done : 1; |
915 | unsigned int file_created : 1; | ||
915 | unsigned int is_recover : 1; | 916 | unsigned int is_recover : 1; |
916 | int rpc_status; | 917 | int rpc_status; |
917 | int cancelled; | 918 | int cancelled; |
@@ -1946,8 +1947,13 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) | |||
1946 | 1947 | ||
1947 | nfs_fattr_map_and_free_names(server, &data->f_attr); | 1948 | nfs_fattr_map_and_free_names(server, &data->f_attr); |
1948 | 1949 | ||
1949 | if (o_arg->open_flags & O_CREAT) | 1950 | if (o_arg->open_flags & O_CREAT) { |
1950 | update_changeattr(dir, &o_res->cinfo); | 1951 | update_changeattr(dir, &o_res->cinfo); |
1952 | if (o_arg->open_flags & O_EXCL) | ||
1953 | data->file_created = 1; | ||
1954 | else if (o_res->cinfo.before != o_res->cinfo.after) | ||
1955 | data->file_created = 1; | ||
1956 | } | ||
1951 | if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) | 1957 | if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) |
1952 | server->caps &= ~NFS_CAP_POSIX_LOCK; | 1958 | server->caps &= ~NFS_CAP_POSIX_LOCK; |
1953 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { | 1959 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { |
@@ -2191,7 +2197,8 @@ static int _nfs4_do_open(struct inode *dir, | |||
2191 | struct nfs_open_context *ctx, | 2197 | struct nfs_open_context *ctx, |
2192 | int flags, | 2198 | int flags, |
2193 | struct iattr *sattr, | 2199 | struct iattr *sattr, |
2194 | struct nfs4_label *label) | 2200 | struct nfs4_label *label, |
2201 | int *opened) | ||
2195 | { | 2202 | { |
2196 | struct nfs4_state_owner *sp; | 2203 | struct nfs4_state_owner *sp; |
2197 | struct nfs4_state *state = NULL; | 2204 | struct nfs4_state *state = NULL; |
@@ -2261,6 +2268,8 @@ static int _nfs4_do_open(struct inode *dir, | |||
2261 | nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel); | 2268 | nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel); |
2262 | } | 2269 | } |
2263 | } | 2270 | } |
2271 | if (opendata->file_created) | ||
2272 | *opened |= FILE_CREATED; | ||
2264 | 2273 | ||
2265 | if (pnfs_use_threshold(ctx_th, opendata->f_attr.mdsthreshold, server)) | 2274 | if (pnfs_use_threshold(ctx_th, opendata->f_attr.mdsthreshold, server)) |
2266 | *ctx_th = opendata->f_attr.mdsthreshold; | 2275 | *ctx_th = opendata->f_attr.mdsthreshold; |
@@ -2289,7 +2298,8 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, | |||
2289 | struct nfs_open_context *ctx, | 2298 | struct nfs_open_context *ctx, |
2290 | int flags, | 2299 | int flags, |
2291 | struct iattr *sattr, | 2300 | struct iattr *sattr, |
2292 | struct nfs4_label *label) | 2301 | struct nfs4_label *label, |
2302 | int *opened) | ||
2293 | { | 2303 | { |
2294 | struct nfs_server *server = NFS_SERVER(dir); | 2304 | struct nfs_server *server = NFS_SERVER(dir); |
2295 | struct nfs4_exception exception = { }; | 2305 | struct nfs4_exception exception = { }; |
@@ -2297,7 +2307,7 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, | |||
2297 | int status; | 2307 | int status; |
2298 | 2308 | ||
2299 | do { | 2309 | do { |
2300 | status = _nfs4_do_open(dir, ctx, flags, sattr, label); | 2310 | status = _nfs4_do_open(dir, ctx, flags, sattr, label, opened); |
2301 | res = ctx->state; | 2311 | res = ctx->state; |
2302 | trace_nfs4_open_file(ctx, flags, status); | 2312 | trace_nfs4_open_file(ctx, flags, status); |
2303 | if (status == 0) | 2313 | if (status == 0) |
@@ -2659,7 +2669,8 @@ out: | |||
2659 | } | 2669 | } |
2660 | 2670 | ||
2661 | static struct inode * | 2671 | static struct inode * |
2662 | nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr) | 2672 | nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, |
2673 | int open_flags, struct iattr *attr, int *opened) | ||
2663 | { | 2674 | { |
2664 | struct nfs4_state *state; | 2675 | struct nfs4_state *state; |
2665 | struct nfs4_label l = {0, 0, 0, NULL}, *label = NULL; | 2676 | struct nfs4_label l = {0, 0, 0, NULL}, *label = NULL; |
@@ -2667,7 +2678,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags | |||
2667 | label = nfs4_label_init_security(dir, ctx->dentry, attr, &l); | 2678 | label = nfs4_label_init_security(dir, ctx->dentry, attr, &l); |
2668 | 2679 | ||
2669 | /* Protect against concurrent sillydeletes */ | 2680 | /* Protect against concurrent sillydeletes */ |
2670 | state = nfs4_do_open(dir, ctx, open_flags, attr, label); | 2681 | state = nfs4_do_open(dir, ctx, open_flags, attr, label, opened); |
2671 | 2682 | ||
2672 | nfs4_label_release_security(label); | 2683 | nfs4_label_release_security(label); |
2673 | 2684 | ||
@@ -3332,6 +3343,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
3332 | struct nfs4_label l, *ilabel = NULL; | 3343 | struct nfs4_label l, *ilabel = NULL; |
3333 | struct nfs_open_context *ctx; | 3344 | struct nfs_open_context *ctx; |
3334 | struct nfs4_state *state; | 3345 | struct nfs4_state *state; |
3346 | int opened = 0; | ||
3335 | int status = 0; | 3347 | int status = 0; |
3336 | 3348 | ||
3337 | ctx = alloc_nfs_open_context(dentry, FMODE_READ); | 3349 | ctx = alloc_nfs_open_context(dentry, FMODE_READ); |
@@ -3341,7 +3353,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
3341 | ilabel = nfs4_label_init_security(dir, dentry, sattr, &l); | 3353 | ilabel = nfs4_label_init_security(dir, dentry, sattr, &l); |
3342 | 3354 | ||
3343 | sattr->ia_mode &= ~current_umask(); | 3355 | sattr->ia_mode &= ~current_umask(); |
3344 | state = nfs4_do_open(dir, ctx, flags, sattr, ilabel); | 3356 | state = nfs4_do_open(dir, ctx, flags, sattr, ilabel, &opened); |
3345 | if (IS_ERR(state)) { | 3357 | if (IS_ERR(state)) { |
3346 | status = PTR_ERR(state); | 3358 | status = PTR_ERR(state); |
3347 | goto out; | 3359 | goto out; |
@@ -7564,8 +7576,10 @@ nfs41_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle, | |||
7564 | { | 7576 | { |
7565 | int err; | 7577 | int err; |
7566 | struct page *page; | 7578 | struct page *page; |
7567 | rpc_authflavor_t flavor; | 7579 | rpc_authflavor_t flavor = RPC_AUTH_MAXFLAVOR; |
7568 | struct nfs4_secinfo_flavors *flavors; | 7580 | struct nfs4_secinfo_flavors *flavors; |
7581 | struct nfs4_secinfo4 *secinfo; | ||
7582 | int i; | ||
7569 | 7583 | ||
7570 | page = alloc_page(GFP_KERNEL); | 7584 | page = alloc_page(GFP_KERNEL); |
7571 | if (!page) { | 7585 | if (!page) { |
@@ -7587,9 +7601,31 @@ nfs41_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle, | |||
7587 | if (err) | 7601 | if (err) |
7588 | goto out_freepage; | 7602 | goto out_freepage; |
7589 | 7603 | ||
7590 | flavor = nfs_find_best_sec(flavors); | 7604 | for (i = 0; i < flavors->num_flavors; i++) { |
7591 | if (err == 0) | 7605 | secinfo = &flavors->flavors[i]; |
7592 | err = nfs4_lookup_root_sec(server, fhandle, info, flavor); | 7606 | |
7607 | switch (secinfo->flavor) { | ||
7608 | case RPC_AUTH_NULL: | ||
7609 | case RPC_AUTH_UNIX: | ||
7610 | case RPC_AUTH_GSS: | ||
7611 | flavor = rpcauth_get_pseudoflavor(secinfo->flavor, | ||
7612 | &secinfo->flavor_info); | ||
7613 | break; | ||
7614 | default: | ||
7615 | flavor = RPC_AUTH_MAXFLAVOR; | ||
7616 | break; | ||
7617 | } | ||
7618 | |||
7619 | if (flavor != RPC_AUTH_MAXFLAVOR) { | ||
7620 | err = nfs4_lookup_root_sec(server, fhandle, | ||
7621 | info, flavor); | ||
7622 | if (!err) | ||
7623 | break; | ||
7624 | } | ||
7625 | } | ||
7626 | |||
7627 | if (flavor == RPC_AUTH_MAXFLAVOR) | ||
7628 | err = -EPERM; | ||
7593 | 7629 | ||
7594 | out_freepage: | 7630 | out_freepage: |
7595 | put_page(page); | 7631 | put_page(page); |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 01fd84b566f7..49f52c8f4422 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -1455,7 +1455,8 @@ struct nfs_rpc_ops { | |||
1455 | struct inode * (*open_context) (struct inode *dir, | 1455 | struct inode * (*open_context) (struct inode *dir, |
1456 | struct nfs_open_context *ctx, | 1456 | struct nfs_open_context *ctx, |
1457 | int open_flags, | 1457 | int open_flags, |
1458 | struct iattr *iattr); | 1458 | struct iattr *iattr, |
1459 | int *); | ||
1459 | int (*have_delegation)(struct inode *, fmode_t); | 1460 | int (*have_delegation)(struct inode *, fmode_t); |
1460 | int (*return_delegation)(struct inode *); | 1461 | int (*return_delegation)(struct inode *); |
1461 | struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *); | 1462 | struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *); |