NFS Client Bugfixes for Linux 6.14-rc
Stable Fixes: * O_DIRECT writes should adjust file length Other Bugfixes: * Adjust delegated timestamps for O_DIRECT reads and writes * Prevent looping due to rpc_signal_task() races * Fix a deadlock when recovering state on a sillyrenamed file * Properly handle -ETIMEDOUT errors from tlshd * Suppress build warnings for unused procfs functions * Fix memory leak of lsm_contexts -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEnZ5MQTpR7cLU7KEp18tUv7ClQOsFAme/L4gACgkQ18tUv7Cl QOsRxRAAyztxWRN/PWabOIu2ZfqvC2Z963B6YE1/jAXeSvBkaCOMca1I8cj7eqiY tpVGB+qUOfKSGhKFL1Zvy5UoewemWhDH/AunNN4cYgBJKaqz4+do6nYH9qkWqnsP kiXu2M+j3/HClk07y3ZNUllGHpJPEVz24iC+VJ/iKHWxUCqxqJrJfzX6ylwhq/Fi Nrlze49AVrywDaNjXNKnbGlUlTcDHyIJCtb2/aSkvJtdnTgD0kKvwTdEjQ205hBs JO1DEAEt9hxsMVETuluUxw7zkJ91SPII3lGo9lVSKqaNSXyPJFfO4HWPEXfhSsbY vEa3J4U26qUKggDZuBZijcN8di0O7+gKfD/s/GpmgvE9tzH7lFjKyQa5gwQmvRv0 PAY1QZyUCmfxkc4yVVXd+WqHzUU+nK2MFrNjbzoDSHWRktZKQcQwWGd+sCu284pq Qnie8XIdl4PqziRn+AvlbV93RGN90Y8You0Y+xGPbGxMTP9vy1s10GF44zwHfqyf 9H7Lcqidms709rMnOGHr/SpdG3G8k0VscirTqi8WPCDBUNyhJuPqcIAAmIeAt6D6 VA6NgDfBhd4uIIo+krntggBkenkXLJJBI2VT+qkRx/Uo+0i2rLEjpIcubLRTFjY3 YxRYvzSxfPcy4Fiwx/Y8IfYZb3gDLXy2sHZBjfOSwyBKHUaT0Hk= =Deh3 -----END PGP SIGNATURE----- Merge tag 'nfs-for-6.14-2' of git://git.linux-nfs.org/projects/anna/linux-nfs Pull NFS client fixes from Anna Schumaker: "Stable Fixes: - O_DIRECT writes should adjust file length Other Bugfixes: - Adjust delegated timestamps for O_DIRECT reads and writes - Prevent looping due to rpc_signal_task() races - Fix a deadlock when recovering state on a sillyrenamed file - Properly handle -ETIMEDOUT errors from tlshd - Suppress build warnings for unused procfs functions - Fix memory leak of lsm_contexts" * tag 'nfs-for-6.14-2' of git://git.linux-nfs.org/projects/anna/linux-nfs: lsm,nfs: fix memory leak of lsm_context sunrpc: suppress warnings for unused procfs functions SUNRPC: Handle -ETIMEDOUT return from tlshd NFSv4: Fix a deadlock when recovering state on a sillyrenamed file SUNRPC: Prevent looping due to rpc_signal_task() races NFS: Adjust delegated timestamps for O_DIRECT reads and writes NFS: O_DIRECT writes must check and adjust the file length
This commit is contained in:
commit
5394eea106
10 changed files with 83 additions and 17 deletions
|
@ -780,6 +780,43 @@ int nfs4_inode_return_delegation(struct inode *inode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs4_inode_set_return_delegation_on_close - asynchronously return a delegation
|
||||
* @inode: inode to process
|
||||
*
|
||||
* This routine is called to request that the delegation be returned as soon
|
||||
* as the file is closed. If the file is already closed, the delegation is
|
||||
* immediately returned.
|
||||
*/
|
||||
void nfs4_inode_set_return_delegation_on_close(struct inode *inode)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
struct nfs_delegation *ret = NULL;
|
||||
|
||||
if (!inode)
|
||||
return;
|
||||
rcu_read_lock();
|
||||
delegation = nfs4_get_valid_delegation(inode);
|
||||
if (!delegation)
|
||||
goto out;
|
||||
spin_lock(&delegation->lock);
|
||||
if (!delegation->inode)
|
||||
goto out_unlock;
|
||||
if (list_empty(&NFS_I(inode)->open_files) &&
|
||||
!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
|
||||
/* Refcount matched in nfs_end_delegation_return() */
|
||||
ret = nfs_get_delegation(delegation);
|
||||
} else
|
||||
set_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags);
|
||||
out_unlock:
|
||||
spin_unlock(&delegation->lock);
|
||||
if (ret)
|
||||
nfs_clear_verifier_delegated(inode);
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
nfs_end_delegation_return(inode, ret, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs4_inode_return_delegation_on_close - asynchronously return a delegation
|
||||
* @inode: inode to process
|
||||
|
|
|
@ -49,6 +49,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
|
|||
unsigned long pagemod_limit, u32 deleg_type);
|
||||
int nfs4_inode_return_delegation(struct inode *inode);
|
||||
void nfs4_inode_return_delegation_on_close(struct inode *inode);
|
||||
void nfs4_inode_set_return_delegation_on_close(struct inode *inode);
|
||||
int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);
|
||||
void nfs_inode_evict_delegation(struct inode *inode);
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <linux/uaccess.h>
|
||||
#include <linux/atomic.h>
|
||||
|
||||
#include "delegation.h"
|
||||
#include "internal.h"
|
||||
#include "iostat.h"
|
||||
#include "pnfs.h"
|
||||
|
@ -130,6 +131,20 @@ static void nfs_direct_truncate_request(struct nfs_direct_req *dreq,
|
|||
dreq->count = req_start;
|
||||
}
|
||||
|
||||
static void nfs_direct_file_adjust_size_locked(struct inode *inode,
|
||||
loff_t offset, size_t count)
|
||||
{
|
||||
loff_t newsize = offset + (loff_t)count;
|
||||
loff_t oldsize = i_size_read(inode);
|
||||
|
||||
if (newsize > oldsize) {
|
||||
i_size_write(inode, newsize);
|
||||
NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_SIZE;
|
||||
trace_nfs_size_grow(inode, newsize);
|
||||
nfs_inc_stats(inode, NFSIOS_EXTENDWRITE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_swap_rw - NFS address space operation for swap I/O
|
||||
* @iocb: target I/O control block
|
||||
|
@ -272,6 +287,8 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
|
|||
nfs_direct_count_bytes(dreq, hdr);
|
||||
spin_unlock(&dreq->lock);
|
||||
|
||||
nfs_update_delegated_atime(dreq->inode);
|
||||
|
||||
while (!list_empty(&hdr->pages)) {
|
||||
struct nfs_page *req = nfs_list_entry(hdr->pages.next);
|
||||
struct page *page = req->wb_page;
|
||||
|
@ -741,6 +758,7 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
|
|||
struct nfs_direct_req *dreq = hdr->dreq;
|
||||
struct nfs_commit_info cinfo;
|
||||
struct nfs_page *req = nfs_list_entry(hdr->pages.next);
|
||||
struct inode *inode = dreq->inode;
|
||||
int flags = NFS_ODIRECT_DONE;
|
||||
|
||||
trace_nfs_direct_write_completion(dreq);
|
||||
|
@ -762,6 +780,11 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
|
|||
}
|
||||
spin_unlock(&dreq->lock);
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
nfs_direct_file_adjust_size_locked(inode, dreq->io_start, dreq->count);
|
||||
nfs_update_delegated_mtime_locked(dreq->inode);
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
||||
while (!list_empty(&hdr->pages)) {
|
||||
|
||||
req = nfs_list_entry(hdr->pages.next);
|
||||
|
|
|
@ -133,6 +133,7 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,
|
|||
if (err)
|
||||
return NULL;
|
||||
|
||||
label->lsmid = shim.id;
|
||||
label->label = shim.context;
|
||||
label->len = shim.len;
|
||||
return label;
|
||||
|
@ -145,7 +146,7 @@ nfs4_label_release_security(struct nfs4_label *label)
|
|||
if (label) {
|
||||
shim.context = label->label;
|
||||
shim.len = label->len;
|
||||
shim.id = LSM_ID_UNDEF;
|
||||
shim.id = label->lsmid;
|
||||
security_release_secctx(&shim);
|
||||
}
|
||||
}
|
||||
|
@ -3906,8 +3907,11 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx,
|
|||
|
||||
static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
|
||||
{
|
||||
struct dentry *dentry = ctx->dentry;
|
||||
if (ctx->state == NULL)
|
||||
return;
|
||||
if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
|
||||
nfs4_inode_set_return_delegation_on_close(d_inode(dentry));
|
||||
if (is_sync)
|
||||
nfs4_close_sync(ctx->state, _nfs4_ctx_to_openmode(ctx));
|
||||
else
|
||||
|
@ -6269,7 +6273,7 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf,
|
|||
size_t buflen)
|
||||
{
|
||||
struct nfs_server *server = NFS_SERVER(inode);
|
||||
struct nfs4_label label = {0, 0, buflen, buf};
|
||||
struct nfs4_label label = {0, 0, 0, buflen, buf};
|
||||
|
||||
u32 bitmask[3] = { 0, 0, FATTR4_WORD2_SECURITY_LABEL };
|
||||
struct nfs_fattr fattr = {
|
||||
|
@ -6374,7 +6378,7 @@ static int nfs4_do_set_security_label(struct inode *inode,
|
|||
static int
|
||||
nfs4_set_security_label(struct inode *inode, const void *buf, size_t buflen)
|
||||
{
|
||||
struct nfs4_label ilabel = {0, 0, buflen, (char *)buf };
|
||||
struct nfs4_label ilabel = {0, 0, 0, buflen, (char *)buf };
|
||||
struct nfs_fattr *fattr;
|
||||
int status;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ struct nfs4_acl {
|
|||
struct nfs4_label {
|
||||
uint32_t lfs;
|
||||
uint32_t pi;
|
||||
u32 lsmid;
|
||||
u32 len;
|
||||
char *label;
|
||||
};
|
||||
|
|
|
@ -158,7 +158,6 @@ enum {
|
|||
RPC_TASK_NEED_XMIT,
|
||||
RPC_TASK_NEED_RECV,
|
||||
RPC_TASK_MSG_PIN_WAIT,
|
||||
RPC_TASK_SIGNALLED,
|
||||
};
|
||||
|
||||
#define rpc_test_and_set_running(t) \
|
||||
|
@ -171,7 +170,7 @@ enum {
|
|||
|
||||
#define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate)
|
||||
|
||||
#define RPC_SIGNALLED(t) test_bit(RPC_TASK_SIGNALLED, &(t)->tk_runstate)
|
||||
#define RPC_SIGNALLED(t) (READ_ONCE(task->tk_rpc_status) == -ERESTARTSYS)
|
||||
|
||||
/*
|
||||
* Task priorities.
|
||||
|
|
|
@ -360,8 +360,7 @@ TRACE_EVENT(rpc_request,
|
|||
{ (1UL << RPC_TASK_ACTIVE), "ACTIVE" }, \
|
||||
{ (1UL << RPC_TASK_NEED_XMIT), "NEED_XMIT" }, \
|
||||
{ (1UL << RPC_TASK_NEED_RECV), "NEED_RECV" }, \
|
||||
{ (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" }, \
|
||||
{ (1UL << RPC_TASK_SIGNALLED), "SIGNALLED" })
|
||||
{ (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" })
|
||||
|
||||
DECLARE_EVENT_CLASS(rpc_task_running,
|
||||
|
||||
|
|
|
@ -1674,12 +1674,14 @@ static void remove_cache_proc_entries(struct cache_detail *cd)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
|
||||
{
|
||||
struct proc_dir_entry *p;
|
||||
struct sunrpc_net *sn;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_PROC_FS))
|
||||
return 0;
|
||||
|
||||
sn = net_generic(net, sunrpc_net_id);
|
||||
cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc);
|
||||
if (cd->procfs == NULL)
|
||||
|
@ -1707,12 +1709,6 @@ out_nomem:
|
|||
remove_cache_proc_entries(cd);
|
||||
return -ENOMEM;
|
||||
}
|
||||
#else /* CONFIG_PROC_FS */
|
||||
static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void __init cache_initialize(void)
|
||||
{
|
||||
|
|
|
@ -864,8 +864,6 @@ void rpc_signal_task(struct rpc_task *task)
|
|||
if (!rpc_task_set_rpc_status(task, -ERESTARTSYS))
|
||||
return;
|
||||
trace_rpc_task_signalled(task, task->tk_action);
|
||||
set_bit(RPC_TASK_SIGNALLED, &task->tk_runstate);
|
||||
smp_mb__after_atomic();
|
||||
queue = READ_ONCE(task->tk_waitqueue);
|
||||
if (queue)
|
||||
rpc_wake_up_queued_task(queue, task);
|
||||
|
|
|
@ -2581,7 +2581,15 @@ static void xs_tls_handshake_done(void *data, int status, key_serial_t peerid)
|
|||
struct sock_xprt *lower_transport =
|
||||
container_of(lower_xprt, struct sock_xprt, xprt);
|
||||
|
||||
lower_transport->xprt_err = status ? -EACCES : 0;
|
||||
switch (status) {
|
||||
case 0:
|
||||
case -EACCES:
|
||||
case -ETIMEDOUT:
|
||||
lower_transport->xprt_err = status;
|
||||
break;
|
||||
default:
|
||||
lower_transport->xprt_err = -EACCES;
|
||||
}
|
||||
complete(&lower_transport->handshake_done);
|
||||
xprt_put(lower_xprt);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue