Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2086344ybb; Fri, 29 Mar 2019 18:43:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyLZwqT8IfECLtwTMTuNj8STPipX4GXLRqyXh+/UIINiOztbaPOx0odyce6Oke43RSQwQu X-Received: by 2002:aa7:90c7:: with SMTP id k7mr49769436pfk.186.1553910191533; Fri, 29 Mar 2019 18:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553910191; cv=none; d=google.com; s=arc-20160816; b=D5YMTE4XlvcIsH4IflXmG70tsMxFnqJZ7gCK6TmRMOctI+ZVosZYBNqfnjCGgSrMRZ brGO2sgpL/JJ52Q8eeFdP96SY3fNLc7OwrE/9aQW0khu1d2G1iooBnFYQ2I7djzgLPtW o+3ezlEi9yokM3iBpONWJyuUDVRZbIzZQVTd8NdVRaLJwznVhLlG2DGPSe1tKja58QZI 1qTPqdxZVI4ohVOBzwsRT+6CgR4USNAQgFUH0hqeeHC5M7AzI5RZhh5WZnJmsqnSx8LE v1xeKfAJkbevP2QFnyUWiRCcvM1hu3ep2vCg9XJZc5d8+wiWScyEQsPidz/LYpP/XId+ Lhhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AnMBpVDrER3Q3f0dQsHuBYv1tH1cNfoFjnHBB7nqwgw=; b=0Op7osAbW8GC3RqOilHyVuwiZ9SV80Ip4L5PgbayzJmgwJeOKCdMU4H4oRwE4A+H25 NI7Gckj1Jrk91FpstP3BOA/zTHjzFzuhup/VmTgosCUU/2v361R1K0I/2P9hCrta6xB0 EpRsSI74avYFa5agXm25+bABQzFcWGZ1oWY+9aA8hGlu/TYhqkaRSjZ8LfeQ+ZC1p1X7 4l9S0l60qLimd4tHmKB6n3aGi1akSCK4LgKW5rjdaCVfCkWw0bHjPnJhukOopWyFF7zZ 38nzrykuCH1Q+8lTbgCBsZEzoZIvc1rgnf/11kdGfugFH04VGOcr74lBwuMKBpxEojuK ZaAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="M/MOv1DY"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si3266121plf.356.2019.03.29.18.42.56; Fri, 29 Mar 2019 18:43:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="M/MOv1DY"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731483AbfC3BlI (ORCPT + 99 others); Fri, 29 Mar 2019 21:41:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:35814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730707AbfC3B3C (ORCPT ); Fri, 29 Mar 2019 21:29:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4770121773; Sat, 30 Mar 2019 01:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909342; bh=xpAZ4KZ6Gaga+1poFipw3nVNaS/34EQ06nf5xfqgq1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/MOv1DYN7I1EAWgGlFvPeZ5hqvIv+WY+88a9zkxdYn2ktjv2hHKtf0Tpj2OGE3VU 4sLEzNaB4xe7ejH9WhpUYXITF7kCyut1UBPgF4FouvxN8qLVaOYglgaBdlKUJwTqhC viisFjJZJb4v0kCMjHSP9u0NXzusZq3TdT+R4n8Y= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dinu-Razvan Chis-Serban , Dominique Martinet , Sasha Levin , v9fs-developer@lists.sourceforge.net Subject: [PATCH AUTOSEL 4.19 06/57] 9p locks: add mount option for lock retry interval Date: Fri, 29 Mar 2019 21:27:59 -0400 Message-Id: <20190330012854.32212-6-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330012854.32212-1-sashal@kernel.org> References: <20190330012854.32212-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinu-Razvan Chis-Serban [ Upstream commit 5e172f75e51e3de1b4274146d9b990f803cb5c2a ] The default P9_LOCK_TIMEOUT can be too long for some users exporting a local file system to a guest VM (30s), make this configurable at mount time. Link: http://lkml.kernel.org/r/1536295827-3181-1-git-send-email-asmadeus@codewreck.org Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195727 Signed-off-by: Dinu-Razvan Chis-Serban Signed-off-by: Dominique Martinet Signed-off-by: Sasha Levin --- fs/9p/v9fs.c | 21 +++++++++++++++++++++ fs/9p/v9fs.h | 1 + fs/9p/vfs_file.c | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 89bac3d2f05b..619128b55837 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -61,6 +61,8 @@ enum { Opt_cache_loose, Opt_fscache, Opt_mmap, /* Access options */ Opt_access, Opt_posixacl, + /* Lock timeout option */ + Opt_locktimeout, /* Error token */ Opt_err }; @@ -80,6 +82,7 @@ static const match_table_t tokens = { {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, {Opt_posixacl, "posixacl"}, + {Opt_locktimeout, "locktimeout=%u"}, {Opt_err, NULL} }; @@ -187,6 +190,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) #ifdef CONFIG_9P_FSCACHE v9ses->cachetag = NULL; #endif + v9ses->session_lock_timeout = P9_LOCK_TIMEOUT; if (!opts) return 0; @@ -359,6 +363,23 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) #endif break; + case Opt_locktimeout: + r = match_int(&args[0], &option); + if (r < 0) { + p9_debug(P9_DEBUG_ERROR, + "integer field, but no integer?\n"); + ret = r; + continue; + } + if (option < 1) { + p9_debug(P9_DEBUG_ERROR, + "locktimeout must be a greater than zero integer.\n"); + ret = -EINVAL; + continue; + } + v9ses->session_lock_timeout = (long)option * HZ; + break; + default: continue; } diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 982e017acadb..129e5243a6bf 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -116,6 +116,7 @@ struct v9fs_session_info { struct p9_client *clnt; /* 9p client */ struct list_head slist; /* list of sessions registered with v9fs */ struct rw_semaphore rename_sem; + long session_lock_timeout; /* retry interval for blocking locks */ }; /* cache_validity flags */ diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index c87e6d6ec069..05454a7e22dc 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -154,6 +154,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) uint8_t status = P9_LOCK_ERROR; int res = 0; unsigned char fl_type; + struct v9fs_session_info *v9ses; fid = filp->private_data; BUG_ON(fid == NULL); @@ -189,6 +190,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) if (IS_SETLKW(cmd)) flock.flags = P9_LOCK_FLAGS_BLOCK; + v9ses = v9fs_inode2v9ses(file_inode(filp)); + /* * if its a blocked request and we get P9_LOCK_BLOCKED as the status * for lock request, keep on trying @@ -202,7 +205,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) break; if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd)) break; - if (schedule_timeout_interruptible(P9_LOCK_TIMEOUT) != 0) + if (schedule_timeout_interruptible(v9ses->session_lock_timeout) + != 0) break; /* * p9_client_lock_dotl overwrites flock.client_id with the -- 2.19.1