| .. | .. |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | #include "nfs4_fs.h" |
|---|
| 7 | | -#include <linux/mount.h> |
|---|
| 7 | +#include <linux/fs_context.h> |
|---|
| 8 | 8 | #include <linux/security.h> |
|---|
| 9 | 9 | #include <linux/crc32.h> |
|---|
| 10 | +#include <linux/sunrpc/addr.h> |
|---|
| 10 | 11 | #include <linux/nfs_page.h> |
|---|
| 11 | 12 | #include <linux/wait_bit.h> |
|---|
| 12 | 13 | |
|---|
| 13 | | -#define NFS_MS_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS) |
|---|
| 14 | +#define NFS_SB_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS) |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | extern const struct export_operations nfs_export_ops; |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | struct nfs_string; |
|---|
| 18 | | - |
|---|
| 19 | | -/* Maximum number of readahead requests |
|---|
| 20 | | - * FIXME: this should really be a sysctl so that users may tune it to suit |
|---|
| 21 | | - * their needs. People that do NFS over a slow network, might for |
|---|
| 22 | | - * instance want to reduce it to something closer to 1 for improved |
|---|
| 23 | | - * interactive response. |
|---|
| 24 | | - */ |
|---|
| 25 | | -#define NFS_MAX_READAHEAD (RPC_DEF_SLOT_TABLE - 1) |
|---|
| 19 | +struct nfs_pageio_descriptor; |
|---|
| 26 | 20 | |
|---|
| 27 | 21 | static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr) |
|---|
| 28 | 22 | { |
|---|
| .. | .. |
|---|
| 39 | 33 | return 1; |
|---|
| 40 | 34 | } |
|---|
| 41 | 35 | |
|---|
| 42 | | -struct nfs_clone_mount { |
|---|
| 43 | | - const struct super_block *sb; |
|---|
| 44 | | - const struct dentry *dentry; |
|---|
| 45 | | - struct nfs_fh *fh; |
|---|
| 46 | | - struct nfs_fattr *fattr; |
|---|
| 47 | | - char *hostname; |
|---|
| 48 | | - char *mnt_path; |
|---|
| 49 | | - struct sockaddr *addr; |
|---|
| 50 | | - size_t addrlen; |
|---|
| 51 | | - rpc_authflavor_t authflavor; |
|---|
| 52 | | -}; |
|---|
| 36 | +static inline bool nfs_lookup_is_soft_revalidate(const struct dentry *dentry) |
|---|
| 37 | +{ |
|---|
| 38 | + if (!(NFS_SB(dentry->d_sb)->flags & NFS_MOUNT_SOFTREVAL)) |
|---|
| 39 | + return false; |
|---|
| 40 | + if (!d_is_positive(dentry) || !NFS_FH(d_inode(dentry))->size) |
|---|
| 41 | + return false; |
|---|
| 42 | + return true; |
|---|
| 43 | +} |
|---|
| 44 | + |
|---|
| 45 | +static inline fmode_t flags_to_mode(int flags) |
|---|
| 46 | +{ |
|---|
| 47 | + fmode_t res = (__force fmode_t)flags & FMODE_EXEC; |
|---|
| 48 | + if ((flags & O_ACCMODE) != O_WRONLY) |
|---|
| 49 | + res |= FMODE_READ; |
|---|
| 50 | + if ((flags & O_ACCMODE) != O_RDONLY) |
|---|
| 51 | + res |= FMODE_WRITE; |
|---|
| 52 | + return res; |
|---|
| 53 | +} |
|---|
| 53 | 54 | |
|---|
| 54 | 55 | /* |
|---|
| 55 | 56 | * Note: RFC 1813 doesn't limit the number of auth flavors that |
|---|
| .. | .. |
|---|
| 81 | 82 | struct nfs_subversion *nfs_mod; |
|---|
| 82 | 83 | int proto; |
|---|
| 83 | 84 | u32 minorversion; |
|---|
| 85 | + unsigned int nconnect; |
|---|
| 84 | 86 | struct net *net; |
|---|
| 85 | 87 | const struct rpc_timeout *timeparms; |
|---|
| 88 | + const struct cred *cred; |
|---|
| 86 | 89 | }; |
|---|
| 87 | 90 | |
|---|
| 88 | 91 | /* |
|---|
| 89 | 92 | * In-kernel mount arguments |
|---|
| 90 | 93 | */ |
|---|
| 91 | | -struct nfs_parsed_mount_data { |
|---|
| 92 | | - int flags; |
|---|
| 94 | +struct nfs_fs_context { |
|---|
| 95 | + bool internal; |
|---|
| 96 | + bool skip_reconfig_option_check; |
|---|
| 97 | + bool need_mount; |
|---|
| 98 | + bool sloppy; |
|---|
| 99 | + unsigned int flags; /* NFS{,4}_MOUNT_* flags */ |
|---|
| 93 | 100 | unsigned int rsize, wsize; |
|---|
| 94 | 101 | unsigned int timeo, retrans; |
|---|
| 95 | | - unsigned int acregmin, acregmax, |
|---|
| 96 | | - acdirmin, acdirmax; |
|---|
| 102 | + unsigned int acregmin, acregmax; |
|---|
| 103 | + unsigned int acdirmin, acdirmax; |
|---|
| 97 | 104 | unsigned int namlen; |
|---|
| 98 | 105 | unsigned int options; |
|---|
| 99 | 106 | unsigned int bsize; |
|---|
| .. | .. |
|---|
| 103 | 110 | unsigned int version; |
|---|
| 104 | 111 | unsigned int minorversion; |
|---|
| 105 | 112 | char *fscache_uniq; |
|---|
| 106 | | - bool need_mount; |
|---|
| 113 | + unsigned short protofamily; |
|---|
| 114 | + unsigned short mountfamily; |
|---|
| 107 | 115 | |
|---|
| 108 | 116 | struct { |
|---|
| 109 | | - struct sockaddr_storage address; |
|---|
| 117 | + union { |
|---|
| 118 | + struct sockaddr address; |
|---|
| 119 | + struct sockaddr_storage _address; |
|---|
| 120 | + }; |
|---|
| 110 | 121 | size_t addrlen; |
|---|
| 111 | 122 | char *hostname; |
|---|
| 112 | 123 | u32 version; |
|---|
| .. | .. |
|---|
| 115 | 126 | } mount_server; |
|---|
| 116 | 127 | |
|---|
| 117 | 128 | struct { |
|---|
| 118 | | - struct sockaddr_storage address; |
|---|
| 129 | + union { |
|---|
| 130 | + struct sockaddr address; |
|---|
| 131 | + struct sockaddr_storage _address; |
|---|
| 132 | + }; |
|---|
| 119 | 133 | size_t addrlen; |
|---|
| 120 | 134 | char *hostname; |
|---|
| 121 | 135 | char *export_path; |
|---|
| 122 | 136 | int port; |
|---|
| 123 | 137 | unsigned short protocol; |
|---|
| 138 | + unsigned short nconnect; |
|---|
| 139 | + unsigned short export_path_len; |
|---|
| 124 | 140 | } nfs_server; |
|---|
| 125 | 141 | |
|---|
| 126 | | - struct security_mnt_opts lsm_opts; |
|---|
| 127 | | - struct net *net; |
|---|
| 142 | + struct nfs_fh *mntfh; |
|---|
| 143 | + struct nfs_server *server; |
|---|
| 144 | + struct nfs_subversion *nfs_mod; |
|---|
| 145 | + |
|---|
| 146 | + /* Information for a cloned mount. */ |
|---|
| 147 | + struct nfs_clone_mount { |
|---|
| 148 | + struct super_block *sb; |
|---|
| 149 | + struct dentry *dentry; |
|---|
| 150 | + struct nfs_fattr *fattr; |
|---|
| 151 | + unsigned int inherited_bsize; |
|---|
| 152 | + } clone_data; |
|---|
| 128 | 153 | }; |
|---|
| 154 | + |
|---|
| 155 | +#define nfs_errorf(fc, fmt, ...) ((fc)->log.log ? \ |
|---|
| 156 | + errorf(fc, fmt, ## __VA_ARGS__) : \ |
|---|
| 157 | + ({ dprintk(fmt "\n", ## __VA_ARGS__); })) |
|---|
| 158 | + |
|---|
| 159 | +#define nfs_ferrorf(fc, fac, fmt, ...) ((fc)->log.log ? \ |
|---|
| 160 | + errorf(fc, fmt, ## __VA_ARGS__) : \ |
|---|
| 161 | + ({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); })) |
|---|
| 162 | + |
|---|
| 163 | +#define nfs_invalf(fc, fmt, ...) ((fc)->log.log ? \ |
|---|
| 164 | + invalf(fc, fmt, ## __VA_ARGS__) : \ |
|---|
| 165 | + ({ dprintk(fmt "\n", ## __VA_ARGS__); -EINVAL; })) |
|---|
| 166 | + |
|---|
| 167 | +#define nfs_finvalf(fc, fac, fmt, ...) ((fc)->log.log ? \ |
|---|
| 168 | + invalf(fc, fmt, ## __VA_ARGS__) : \ |
|---|
| 169 | + ({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); -EINVAL; })) |
|---|
| 170 | + |
|---|
| 171 | +#define nfs_warnf(fc, fmt, ...) ((fc)->log.log ? \ |
|---|
| 172 | + warnf(fc, fmt, ## __VA_ARGS__) : \ |
|---|
| 173 | + ({ dprintk(fmt "\n", ## __VA_ARGS__); })) |
|---|
| 174 | + |
|---|
| 175 | +#define nfs_fwarnf(fc, fac, fmt, ...) ((fc)->log.log ? \ |
|---|
| 176 | + warnf(fc, fmt, ## __VA_ARGS__) : \ |
|---|
| 177 | + ({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); })) |
|---|
| 178 | + |
|---|
| 179 | +static inline struct nfs_fs_context *nfs_fc2context(const struct fs_context *fc) |
|---|
| 180 | +{ |
|---|
| 181 | + return fc->fs_private; |
|---|
| 182 | +} |
|---|
| 129 | 183 | |
|---|
| 130 | 184 | /* mount_clnt.c */ |
|---|
| 131 | 185 | struct nfs_mount_request { |
|---|
| .. | .. |
|---|
| 142 | 196 | struct net *net; |
|---|
| 143 | 197 | }; |
|---|
| 144 | 198 | |
|---|
| 145 | | -struct nfs_mount_info { |
|---|
| 146 | | - void (*fill_super)(struct super_block *, struct nfs_mount_info *); |
|---|
| 147 | | - int (*set_security)(struct super_block *, struct dentry *, struct nfs_mount_info *); |
|---|
| 148 | | - struct nfs_parsed_mount_data *parsed; |
|---|
| 149 | | - struct nfs_clone_mount *cloned; |
|---|
| 150 | | - struct nfs_fh *mntfh; |
|---|
| 151 | | -}; |
|---|
| 152 | | - |
|---|
| 153 | 199 | extern int nfs_mount(struct nfs_mount_request *info); |
|---|
| 154 | 200 | extern void nfs_umount(const struct nfs_mount_request *info); |
|---|
| 155 | 201 | |
|---|
| 156 | 202 | /* client.c */ |
|---|
| 157 | 203 | extern const struct rpc_program nfs_program; |
|---|
| 158 | 204 | extern void nfs_clients_init(struct net *net); |
|---|
| 205 | +extern void nfs_clients_exit(struct net *net); |
|---|
| 159 | 206 | extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *); |
|---|
| 160 | 207 | int nfs_create_rpc_client(struct nfs_client *, const struct nfs_client_initdata *, rpc_authflavor_t); |
|---|
| 161 | 208 | struct nfs_client *nfs_get_client(const struct nfs_client_initdata *); |
|---|
| .. | .. |
|---|
| 168 | 215 | struct nfs_server *nfs_alloc_server(void); |
|---|
| 169 | 216 | void nfs_server_copy_userdata(struct nfs_server *, struct nfs_server *); |
|---|
| 170 | 217 | |
|---|
| 171 | | -extern void nfs_cleanup_cb_ident_idr(struct net *); |
|---|
| 172 | 218 | extern void nfs_put_client(struct nfs_client *); |
|---|
| 173 | 219 | extern void nfs_free_client(struct nfs_client *); |
|---|
| 174 | 220 | extern struct nfs_client *nfs4_find_client_ident(struct net *, int); |
|---|
| 175 | 221 | extern struct nfs_client * |
|---|
| 176 | 222 | nfs4_find_client_sessionid(struct net *, const struct sockaddr *, |
|---|
| 177 | 223 | struct nfs4_sessionid *, u32); |
|---|
| 178 | | -extern struct nfs_server *nfs_create_server(struct nfs_mount_info *, |
|---|
| 179 | | - struct nfs_subversion *); |
|---|
| 180 | | -extern struct nfs_server *nfs4_create_server( |
|---|
| 181 | | - struct nfs_mount_info *, |
|---|
| 182 | | - struct nfs_subversion *); |
|---|
| 183 | | -extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, |
|---|
| 184 | | - struct nfs_fh *); |
|---|
| 224 | +extern struct nfs_server *nfs_create_server(struct fs_context *); |
|---|
| 225 | +extern struct nfs_server *nfs4_create_server(struct fs_context *); |
|---|
| 226 | +extern struct nfs_server *nfs4_create_referral_server(struct fs_context *); |
|---|
| 185 | 227 | extern int nfs4_update_server(struct nfs_server *server, const char *hostname, |
|---|
| 186 | 228 | struct sockaddr *sap, size_t salen, |
|---|
| 187 | 229 | struct net *net); |
|---|
| .. | .. |
|---|
| 232 | 274 | extern const struct svc_version nfs4_callback_version1; |
|---|
| 233 | 275 | extern const struct svc_version nfs4_callback_version4; |
|---|
| 234 | 276 | |
|---|
| 235 | | -struct nfs_pageio_descriptor; |
|---|
| 277 | +/* fs_context.c */ |
|---|
| 278 | +extern struct file_system_type nfs_fs_type; |
|---|
| 279 | + |
|---|
| 236 | 280 | /* pagelist.c */ |
|---|
| 237 | 281 | extern int __init nfs_init_nfspagecache(void); |
|---|
| 238 | 282 | extern void nfs_destroy_nfspagecache(void); |
|---|
| .. | .. |
|---|
| 254 | 298 | void nfs_pgio_header_free(struct nfs_pgio_header *); |
|---|
| 255 | 299 | int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *); |
|---|
| 256 | 300 | int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr, |
|---|
| 257 | | - struct rpc_cred *cred, const struct nfs_rpc_ops *rpc_ops, |
|---|
| 301 | + const struct cred *cred, const struct nfs_rpc_ops *rpc_ops, |
|---|
| 258 | 302 | const struct rpc_call_ops *call_ops, int how, int flags); |
|---|
| 259 | 303 | void nfs_free_request(struct nfs_page *req); |
|---|
| 260 | 304 | struct nfs_pgio_mirror * |
|---|
| 261 | 305 | nfs_pgio_current_mirror(struct nfs_pageio_descriptor *desc); |
|---|
| 262 | 306 | |
|---|
| 263 | | -static inline bool nfs_pgio_has_mirroring(struct nfs_pageio_descriptor *desc) |
|---|
| 264 | | -{ |
|---|
| 265 | | - WARN_ON_ONCE(desc->pg_mirror_count < 1); |
|---|
| 266 | | - return desc->pg_mirror_count > 1; |
|---|
| 267 | | -} |
|---|
| 268 | | - |
|---|
| 269 | 307 | static inline bool nfs_match_open_context(const struct nfs_open_context *ctx1, |
|---|
| 270 | 308 | const struct nfs_open_context *ctx2) |
|---|
| 271 | 309 | { |
|---|
| 272 | | - return ctx1->cred == ctx2->cred && ctx1->state == ctx2->state; |
|---|
| 310 | + return cred_fscmp(ctx1->cred, ctx2->cred) == 0 && ctx1->state == ctx2->state; |
|---|
| 273 | 311 | } |
|---|
| 274 | 312 | |
|---|
| 275 | 313 | /* nfs2xdr.c */ |
|---|
| .. | .. |
|---|
| 380 | 418 | /* inode.c */ |
|---|
| 381 | 419 | extern struct workqueue_struct *nfsiod_workqueue; |
|---|
| 382 | 420 | extern struct inode *nfs_alloc_inode(struct super_block *sb); |
|---|
| 383 | | -extern void nfs_destroy_inode(struct inode *); |
|---|
| 421 | +extern void nfs_free_inode(struct inode *); |
|---|
| 384 | 422 | extern int nfs_write_inode(struct inode *, struct writeback_control *); |
|---|
| 385 | 423 | extern int nfs_drop_inode(struct inode *); |
|---|
| 386 | 424 | extern void nfs_clear_inode(struct inode *); |
|---|
| .. | .. |
|---|
| 392 | 430 | |
|---|
| 393 | 431 | /* super.c */ |
|---|
| 394 | 432 | extern const struct super_operations nfs_sops; |
|---|
| 395 | | -extern struct file_system_type nfs_fs_type; |
|---|
| 396 | | -extern struct file_system_type nfs_xdev_fs_type; |
|---|
| 397 | | -#if IS_ENABLED(CONFIG_NFS_V4) |
|---|
| 398 | | -extern struct file_system_type nfs4_xdev_fs_type; |
|---|
| 399 | | -extern struct file_system_type nfs4_referral_fs_type; |
|---|
| 400 | | -#endif |
|---|
| 401 | 433 | bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t); |
|---|
| 402 | | -struct dentry *nfs_try_mount(int, const char *, struct nfs_mount_info *, |
|---|
| 403 | | - struct nfs_subversion *); |
|---|
| 404 | | -int nfs_set_sb_security(struct super_block *, struct dentry *, struct nfs_mount_info *); |
|---|
| 405 | | -int nfs_clone_sb_security(struct super_block *, struct dentry *, struct nfs_mount_info *); |
|---|
| 406 | | -struct dentry *nfs_fs_mount_common(struct nfs_server *, int, const char *, |
|---|
| 407 | | - struct nfs_mount_info *, struct nfs_subversion *); |
|---|
| 408 | | -struct dentry *nfs_fs_mount(struct file_system_type *, int, const char *, void *); |
|---|
| 409 | | -struct dentry * nfs_xdev_mount_common(struct file_system_type *, int, |
|---|
| 410 | | - const char *, struct nfs_mount_info *); |
|---|
| 434 | +int nfs_try_get_tree(struct fs_context *); |
|---|
| 435 | +int nfs_get_tree_common(struct fs_context *); |
|---|
| 411 | 436 | void nfs_kill_super(struct super_block *); |
|---|
| 412 | | -void nfs_fill_super(struct super_block *, struct nfs_mount_info *); |
|---|
| 413 | 437 | |
|---|
| 414 | 438 | extern struct rpc_stat nfs_rpcstat; |
|---|
| 415 | 439 | |
|---|
| .. | .. |
|---|
| 417 | 441 | extern void __exit unregister_nfs_fs(void); |
|---|
| 418 | 442 | extern bool nfs_sb_active(struct super_block *sb); |
|---|
| 419 | 443 | extern void nfs_sb_deactive(struct super_block *sb); |
|---|
| 420 | | - |
|---|
| 444 | +extern int nfs_client_for_each_server(struct nfs_client *clp, |
|---|
| 445 | + int (*fn)(struct nfs_server *, void *), |
|---|
| 446 | + void *data); |
|---|
| 421 | 447 | /* io.c */ |
|---|
| 422 | 448 | extern void nfs_start_io_read(struct inode *inode); |
|---|
| 423 | 449 | extern void nfs_end_io_read(struct inode *inode); |
|---|
| .. | .. |
|---|
| 436 | 462 | extern char *nfs_path(char **p, struct dentry *dentry, |
|---|
| 437 | 463 | char *buffer, ssize_t buflen, unsigned flags); |
|---|
| 438 | 464 | extern struct vfsmount *nfs_d_automount(struct path *path); |
|---|
| 439 | | -struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *, |
|---|
| 440 | | - struct nfs_fh *, struct nfs_fattr *); |
|---|
| 441 | | -struct vfsmount *nfs_do_submount(struct dentry *, struct nfs_fh *, |
|---|
| 442 | | - struct nfs_fattr *, rpc_authflavor_t); |
|---|
| 465 | +int nfs_submount(struct fs_context *, struct nfs_server *); |
|---|
| 466 | +int nfs_do_submount(struct fs_context *); |
|---|
| 443 | 467 | |
|---|
| 444 | 468 | /* getroot.c */ |
|---|
| 445 | | -extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *, |
|---|
| 446 | | - const char *); |
|---|
| 469 | +extern int nfs_get_root(struct super_block *s, struct fs_context *fc); |
|---|
| 447 | 470 | #if IS_ENABLED(CONFIG_NFS_V4) |
|---|
| 448 | | -extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *, |
|---|
| 449 | | - const char *); |
|---|
| 450 | | - |
|---|
| 451 | 471 | extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool); |
|---|
| 452 | 472 | #endif |
|---|
| 453 | 473 | |
|---|
| .. | .. |
|---|
| 466 | 486 | int nfs_show_devname(struct seq_file *, struct dentry *); |
|---|
| 467 | 487 | int nfs_show_path(struct seq_file *, struct dentry *); |
|---|
| 468 | 488 | int nfs_show_stats(struct seq_file *, struct dentry *); |
|---|
| 469 | | -int nfs_remount(struct super_block *sb, int *flags, char *raw_data); |
|---|
| 489 | +int nfs_reconfigure(struct fs_context *); |
|---|
| 470 | 490 | |
|---|
| 471 | 491 | /* write.c */ |
|---|
| 472 | 492 | extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, |
|---|
| .. | .. |
|---|
| 521 | 541 | loff_t lstart, loff_t lend); |
|---|
| 522 | 542 | |
|---|
| 523 | 543 | #ifdef CONFIG_NFS_V4_1 |
|---|
| 544 | +static inline void |
|---|
| 545 | +pnfs_bucket_clear_pnfs_ds_commit_verifiers(struct pnfs_commit_bucket *buckets, |
|---|
| 546 | + unsigned int nbuckets) |
|---|
| 547 | +{ |
|---|
| 548 | + unsigned int i; |
|---|
| 549 | + |
|---|
| 550 | + for (i = 0; i < nbuckets; i++) |
|---|
| 551 | + buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW; |
|---|
| 552 | +} |
|---|
| 524 | 553 | static inline |
|---|
| 525 | 554 | void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo) |
|---|
| 526 | 555 | { |
|---|
| 527 | | - int i; |
|---|
| 556 | + struct pnfs_commit_array *array; |
|---|
| 528 | 557 | |
|---|
| 529 | | - for (i = 0; i < cinfo->nbuckets; i++) |
|---|
| 530 | | - cinfo->buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW; |
|---|
| 558 | + rcu_read_lock(); |
|---|
| 559 | + list_for_each_entry_rcu(array, &cinfo->commits, cinfo_list) |
|---|
| 560 | + pnfs_bucket_clear_pnfs_ds_commit_verifiers(array->buckets, |
|---|
| 561 | + array->nbuckets); |
|---|
| 562 | + rcu_read_unlock(); |
|---|
| 531 | 563 | } |
|---|
| 532 | 564 | #else |
|---|
| 533 | 565 | static inline |
|---|
| .. | .. |
|---|
| 548 | 580 | return memcmp(v1->data, v2->data, sizeof(v1->data)); |
|---|
| 549 | 581 | } |
|---|
| 550 | 582 | |
|---|
| 583 | +static inline bool |
|---|
| 584 | +nfs_write_match_verf(const struct nfs_writeverf *verf, |
|---|
| 585 | + struct nfs_page *req) |
|---|
| 586 | +{ |
|---|
| 587 | + return verf->committed > NFS_UNSTABLE && |
|---|
| 588 | + !nfs_write_verifier_cmp(&req->wb_verf, &verf->verifier); |
|---|
| 589 | +} |
|---|
| 590 | + |
|---|
| 591 | +static inline gfp_t nfs_io_gfp_mask(void) |
|---|
| 592 | +{ |
|---|
| 593 | + if (current->flags & PF_WQ_WORKER) |
|---|
| 594 | + return GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; |
|---|
| 595 | + return GFP_KERNEL; |
|---|
| 596 | +} |
|---|
| 597 | + |
|---|
| 551 | 598 | /* unlink.c */ |
|---|
| 552 | 599 | extern struct rpc_task * |
|---|
| 553 | 600 | nfs_async_rename(struct inode *old_dir, struct inode *new_dir, |
|---|
| .. | .. |
|---|
| 565 | 612 | const struct nfs_client_initdata *); |
|---|
| 566 | 613 | extern int nfs40_walk_client_list(struct nfs_client *clp, |
|---|
| 567 | 614 | struct nfs_client **result, |
|---|
| 568 | | - struct rpc_cred *cred); |
|---|
| 615 | + const struct cred *cred); |
|---|
| 569 | 616 | extern int nfs41_walk_client_list(struct nfs_client *clp, |
|---|
| 570 | 617 | struct nfs_client **result, |
|---|
| 571 | | - struct rpc_cred *cred); |
|---|
| 572 | | -extern int nfs4_test_session_trunk(struct rpc_clnt *, |
|---|
| 573 | | - struct rpc_xprt *, |
|---|
| 574 | | - void *); |
|---|
| 618 | + const struct cred *cred); |
|---|
| 619 | +extern void nfs4_test_session_trunk(struct rpc_clnt *clnt, |
|---|
| 620 | + struct rpc_xprt *xprt, |
|---|
| 621 | + void *data); |
|---|
| 575 | 622 | |
|---|
| 576 | 623 | static inline struct inode *nfs_igrab_and_active(struct inode *inode) |
|---|
| 577 | 624 | { |
|---|
| .. | .. |
|---|
| 660 | 707 | } |
|---|
| 661 | 708 | |
|---|
| 662 | 709 | /* |
|---|
| 663 | | - * Record the page as unstable and mark its inode as dirty. |
|---|
| 710 | + * Record the page as unstable (an extra writeback period) and mark its |
|---|
| 711 | + * inode as dirty. |
|---|
| 664 | 712 | */ |
|---|
| 665 | 713 | static inline |
|---|
| 666 | 714 | void nfs_mark_page_unstable(struct page *page, struct nfs_commit_info *cinfo) |
|---|
| .. | .. |
|---|
| 668 | 716 | if (!cinfo->dreq) { |
|---|
| 669 | 717 | struct inode *inode = page_file_mapping(page)->host; |
|---|
| 670 | 718 | |
|---|
| 671 | | - inc_node_page_state(page, NR_UNSTABLE_NFS); |
|---|
| 672 | | - inc_wb_stat(&inode_to_bdi(inode)->wb, WB_RECLAIMABLE); |
|---|
| 719 | + /* This page is really still in write-back - just that the |
|---|
| 720 | + * writeback is happening on the server now. |
|---|
| 721 | + */ |
|---|
| 722 | + inc_node_page_state(page, NR_WRITEBACK); |
|---|
| 723 | + inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); |
|---|
| 673 | 724 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); |
|---|
| 674 | 725 | } |
|---|
| 675 | 726 | } |
|---|
| .. | .. |
|---|
| 714 | 765 | } |
|---|
| 715 | 766 | |
|---|
| 716 | 767 | /* |
|---|
| 717 | | - * Convert a struct timespec into a 64-bit change attribute |
|---|
| 768 | + * Convert a struct timespec64 into a 64-bit change attribute |
|---|
| 718 | 769 | * |
|---|
| 719 | | - * This does approximately the same thing as timespec_to_ns(), |
|---|
| 770 | + * This does approximately the same thing as timespec64_to_ns(), |
|---|
| 720 | 771 | * but for calculation efficiency, we multiply the seconds by |
|---|
| 721 | 772 | * 1024*1024*1024. |
|---|
| 722 | 773 | */ |
|---|
| 723 | 774 | static inline |
|---|
| 724 | | -u64 nfs_timespec_to_change_attr(const struct timespec *ts) |
|---|
| 775 | +u64 nfs_timespec_to_change_attr(const struct timespec64 *ts) |
|---|
| 725 | 776 | { |
|---|
| 726 | 777 | return ((u64)ts->tv_sec << 30) + ts->tv_nsec; |
|---|
| 727 | 778 | } |
|---|
| .. | .. |
|---|
| 758 | 809 | { |
|---|
| 759 | 810 | switch (err) { |
|---|
| 760 | 811 | case -ERESTARTSYS: |
|---|
| 812 | + case -EINTR: |
|---|
| 761 | 813 | case -EACCES: |
|---|
| 762 | 814 | case -EDQUOT: |
|---|
| 763 | 815 | case -EFBIG: |
|---|
| .. | .. |
|---|
| 766 | 818 | case -EROFS: |
|---|
| 767 | 819 | case -ESTALE: |
|---|
| 768 | 820 | case -E2BIG: |
|---|
| 821 | + case -ENOMEM: |
|---|
| 822 | + case -ETIMEDOUT: |
|---|
| 769 | 823 | return true; |
|---|
| 770 | 824 | default: |
|---|
| 771 | 825 | return false; |
|---|
| 772 | 826 | } |
|---|
| 773 | 827 | } |
|---|
| 774 | 828 | |
|---|
| 775 | | -static inline void nfs_context_set_write_error(struct nfs_open_context *ctx, int error) |
|---|
| 829 | +static inline bool nfs_error_is_fatal_on_server(int err) |
|---|
| 776 | 830 | { |
|---|
| 777 | | - ctx->error = error; |
|---|
| 778 | | - smp_wmb(); |
|---|
| 779 | | - set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); |
|---|
| 831 | + switch (err) { |
|---|
| 832 | + case 0: |
|---|
| 833 | + case -ERESTARTSYS: |
|---|
| 834 | + case -EINTR: |
|---|
| 835 | + case -ENOMEM: |
|---|
| 836 | + return false; |
|---|
| 837 | + } |
|---|
| 838 | + return nfs_error_is_fatal(err); |
|---|
| 839 | +} |
|---|
| 840 | + |
|---|
| 841 | +/* |
|---|
| 842 | + * Select between a default port value and a user-specified port value. |
|---|
| 843 | + * If a zero value is set, then autobind will be used. |
|---|
| 844 | + */ |
|---|
| 845 | +static inline void nfs_set_port(struct sockaddr *sap, int *port, |
|---|
| 846 | + const unsigned short default_port) |
|---|
| 847 | +{ |
|---|
| 848 | + if (*port == NFS_UNSPEC_PORT) |
|---|
| 849 | + *port = default_port; |
|---|
| 850 | + |
|---|
| 851 | + rpc_set_port(sap, *port); |
|---|
| 780 | 852 | } |
|---|