History

Keep read and write fds with each nlm_file

We shouldn't really be using a read-only file descriptor to take a write lock. Most filesystems will put up with it. But NFS, for example, won't.

J. Bruce Fields committed 5 years ago

Commit 7f024fc1 parent b6616017 files · +111 −44Browse files

Showing the changes to include/linux/lockd (2 of 7 files). Show all

Unified · Split

2 files
  1. include/linux/lockd/bind.h +2 −1
  2. include/linux/lockd/lockd.h +7 −2
include/linux/lockd/bind.h+2−1
@@ -27,7 +27,8 @@ struct rpc_task; · 26 unmodified lines
2727 struct nlmsvc_binding {
2828 __be32 (*fopen)(struct svc_rqst *,
2929 struct nfs_fh *,
30− struct file **);
30+ struct file **,
31+ int mode);
3132 void (*fclose)(struct file *);
3233 };
3334
include/linux/lockd/lockd.h+7−2
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 #ifndef LINUX_LOCKD_LOCKD_H
1111 #define LINUX_LOCKD_LOCKD_H
1212
13+/* XXX: a lot of this should really be under fs/lockd. */
14+
1315 #include <linux/in.h>
1416 #include <linux/in6.h>
1517 #include <net/ipv6.h>
@@ -154,7 +156,8 @@ struct nlm_rqst { · 138 unmodified lines
154156 struct nlm_file {
155157 struct hlist_node f_list; /* linked list */
156158 struct nfs_fh f_handle; /* NFS file handle */
157− struct file * f_file; /* VFS file pointer */
159+ struct file * f_file[2]; /* VFS file pointers,
160+ indexed by O_ flags */
158161 struct nlm_share * f_shares; /* DOS shares */
159162 struct list_head f_blocks; /* blocked locks */
160163 unsigned int f_locks; /* guesstimate # of locks */
@@ -267,6 +270,7 @@ typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref); · 106 unmodified lines
267270 /*
268271 * Server-side lock handling
269272 */
273+int lock_to_openmode(struct file_lock *);
270274 __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
271275 struct nlm_host *, struct nlm_lock *, int,
272276 struct nlm_cookie *, int);
@@ -301,7 +305,8 @@ int nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr); · 28 unmodified lines
301305
302306 static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
303307 {
304− return locks_inode(file->f_file);
308+ return locks_inode(file->f_file[O_RDONLY] ?
309+ file->f_file[O_RDONLY] : file->f_file[O_WRONLY]);
305310 }
306311
307312 static inline int __nlm_privileged_request4(const struct sockaddr *sap)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t