From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC44D270557 for ; Tue, 2 Dec 2025 22:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764714897; cv=none; b=pZu4yMOZSZOGVgoTm1NXQg826t4xF4ZdKnk7fbLfA0QWs7BzOlyY/IrdkytoHLRX4IeRoW1pCTBYq4kYfskh1PDwcZBTgFXNvJWZhOVK9mj1+RooSlw0erFBfTd012QFQAMiNsrEM1xh6JFgKAt1WFS/CkLpzPxJV1AyJo4kGgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764714897; c=relaxed/simple; bh=knGCB2QWCi7I+b7T8oml1J2JVo/fTrJd+ijEv1ZyS1U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tFHqW14R8fTtp+/Q76lT9Jcw8AL7wyqB1cIblwxRZUSyi8lfpHT3AReAOZzpbfbkm2oHQezw4/42VT3XEsT2b5ykOLZjqX9QRKDOj1c0iwxVUPDo467gzKyeTdcp1c3yuuNwslu7OMvF/p2HaopC1BQbYXnGTvbdlBfIqSLpRl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=S3o9tcEh; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=RuklMzos; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S3o9tcEh"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="RuklMzos" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764714894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I75stScld0jImIWnHzAwTuoOvKajHCPvGtn9toaW0BQ=; b=S3o9tcEha85TpN1QEl8bhFezoSkV/rMN3xpG2KWRyROury1p2rzLebR2/iio+Knm38fbJT bvqY9vnp3CRV/cAS5oY5zV7dT1gnrx+yqelYfEXg9iO0fxvsx7DEoM8s9P76L6N34VX5kn ND7918BMkV/yD+EhYwZ4bbfJY4Xm+3Y= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-y1AW6JZ0Pn-wFs6zq6IqyA-1; Tue, 02 Dec 2025 17:34:53 -0500 X-MC-Unique: y1AW6JZ0Pn-wFs6zq6IqyA-1 X-Mimecast-MFC-AGG-ID: y1AW6JZ0Pn-wFs6zq6IqyA_1764714893 Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7c702347c6eso3983105a34.1 for ; Tue, 02 Dec 2025 14:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1764714893; x=1765319693; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=I75stScld0jImIWnHzAwTuoOvKajHCPvGtn9toaW0BQ=; b=RuklMzosmMWpFYND4EKJ/yEg3C+xck00vLSxCoHH+klZ83U28t78dX0FwUPcaUL9Wn L+G4Hi6UObOEEVJuzPDocPETw5Fqfle7MT/gP+lpYEGtuxEWrpFb+vy9DwAILjOFidFg aTvF6KdOIFp0oIiA9IGYq4HxeqG0+nM+O92mM++5b3ssykV5CvovTnAn6kQOqjeKuepn 7HyHccU6Jy7kQQ4+NokNzAwYvC0FkCuHvstzU75TiuzSiaSNkZ5nsAVZHrfBmEy+THKx BH6KZbxnZ216G7vJq0z2APME5hCER4a6/N41LorYtM5C8I02n1oKyXR32bAyOoSom2+n FfeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764714893; x=1765319693; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I75stScld0jImIWnHzAwTuoOvKajHCPvGtn9toaW0BQ=; b=r8CqysnxO6X7MxpotDM4huI/tw2KGGgemkAb1Id3n/3TH1Pd3dsl80FrELQZ0UDdw2 OImqoG+qPsbl+U/Hf/n+y6ngkyFkQJmxD1GiMv25WYu/YYN1VKpsVruUnpa8r0mnX+/1 RKgFk5jbfOLFqZK18B1zyqxjcqgPlPhY0dnYwwH5n/DmzjafJz3pksQ/xaNXj6D6t0Fb SAZG60+J/nLs+sSvc5dxE5DL176fa1vmFVTZxjNLWe6cdpSXTEpNSGqAvJCQ57mryXPQ RwHADUZZUAcvB9ZWS7XtnsZ4bXL3Wnfzed6ujZ3TIq+t0d1f5/3YAkCyEpbHW2BNQDKr YTfA== X-Forwarded-Encrypted: i=1; AJvYcCVxgv4RNzhai91UaccdUkxmkxwiIZhsYdPkoYWNYhm+dF+r4g24f2LEi0DEFkbeWxrGZngmssMWW1mOmJM=@vger.kernel.org X-Gm-Message-State: AOJu0YwGpdbjYuWNutI9+qd76r9ljSTTjybUhaFZjTpm588YKcKYP+7g glanT8f2W1LOcz96mzV53YPuM7zYQjfyey5XSlN2LoIxaAYEj4eWVhaGhrkGlApvgWDktCS3iT3 y2atDajkMNmmLWHLLJpImKbtfFAxyWriCzyGZYnDEYRB2cLimpmI7b+c5lSNX8w+EQg== X-Gm-Gg: ASbGncuSO+I9fmUI5QEm7WQZRxbI+bftSRieIksmouUqGI3r1VEG2ut0aQEZSnrEqPO zB0SA3QCZvsszsCu2NAU3etayslNmxi/svmm5pkfhI5rurZIexpo7P0ynoJlphDLrRg5Fco9DB4 1Eh2R61WQlYx8n/bzgVx3oOusIsVzKDZW8HXsYBiJxTZfg0dAfhqcDcDNxtX8h/hBJmmpFgu97S jHF1QqAshRtJd0nllOx6PphcDKGOCTh2kQnewjFQOcgnuV/TGxeCh7r3MRfpYS+Xac+gajdTlhj mJPKq8L2Ao5zcsWLrT5Sr6SZw1HXzJlOzB495T8XvRw/10b3Rv4widKHYcuGqxosR5z08872iLB DchCxqgHjRMTR3yD0gF9ZIVyGrDJvLGS8xY5KLd4Iyhqw/mzq2OA= X-Received: by 2002:a05:6830:310b:b0:78e:a394:ca24 with SMTP id 46e09a7af769-7c94db16322mr243460a34.8.1764714892759; Tue, 02 Dec 2025 14:34:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBk5xgbqxkiF0SI2w8qIvhL+LUE6hwtLWp1H8RJuryPPzCLFIrSmuLFBL1JZq1IvKtaEk8Vw== X-Received: by 2002:a05:6830:310b:b0:78e:a394:ca24 with SMTP id 46e09a7af769-7c94db16322mr243453a34.8.1764714892458; Tue, 02 Dec 2025 14:34:52 -0800 (PST) Received: from [10.0.0.82] (97-127-77-149.mpls.qwest.net. [97.127.77.149]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7c90f5d7ba2sm7520115a34.5.2025.12.02.14.34.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Dec 2025 14:34:52 -0800 (PST) Message-ID: <48cdeec9-5bb9-4c7a-a203-39bb8e0ef443@redhat.com> Date: Tue, 2 Dec 2025 16:34:51 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH V3 6/4] 9p: fix new mount API cache option handling To: v9fs@lists.linux.dev Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ericvh@kernel.org, lucho@ionkov.net, asmadeus@codewreck.org, linux_oss@crudebyte.com, eadavis@qq.com, Remi Pommarel References: <20251010214222.1347785-1-sandeen@redhat.com> <20251010214222.1347785-5-sandeen@redhat.com> Content-Language: en-US From: Eric Sandeen In-Reply-To: <20251010214222.1347785-5-sandeen@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit After commit 4eb3117888a92, 9p needs to be able to accept numerical cache= mount options as well as the string "shortcuts" because the option is printed numerically in /proc/mounts rather than by string. This was missed in the mount API conversion, which used an enum for the shortcuts and therefore could not handle a numeric equivalent as an argument to the cache option. Fix this by removing the enum and reverting to the slightly more open-coded option handling for Opt_cache, with the reinstated get_cache_mode() helper. Signed-off-by: Eric Sandeen --- If you wanted to fold this into my original mount api conversion patch so there's no regression point, that would be fine with me as well, of course. Sorry for the error. diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index d684cb406ed6..dea2c5347933 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -72,15 +72,6 @@ static const struct constant_table p9_versions[] = { {} }; -static const struct constant_table p9_cache_mode[] = { - { "loose", CACHE_SC_LOOSE }, - { "fscache", CACHE_SC_FSCACHE }, - { "mmap", CACHE_SC_MMAP }, - { "readahead", CACHE_SC_READAHEAD }, - { "none", CACHE_SC_NONE }, - {} -}; - /* * This structure contains all parameters used for the core code, * the client, and all the transports. @@ -97,7 +88,7 @@ const struct fs_parameter_spec v9fs_param_spec[] = { fsparam_flag ("noxattr", Opt_noxattr), fsparam_flag ("directio", Opt_directio), fsparam_flag ("ignoreqv", Opt_ignoreqv), - fsparam_enum ("cache", Opt_cache, p9_cache_mode), + fsparam_string ("cache", Opt_cache), fsparam_string ("cachetag", Opt_cachetag), fsparam_string ("access", Opt_access), fsparam_flag ("posixacl", Opt_posixacl), @@ -124,6 +115,33 @@ const struct fs_parameter_spec v9fs_param_spec[] = { {} }; +/* Interpret mount options for cache mode */ +static int get_cache_mode(char *s) +{ + int version = -EINVAL; + + if (!strcmp(s, "loose")) { + version = CACHE_SC_LOOSE; + p9_debug(P9_DEBUG_9P, "Cache mode: loose\n"); + } else if (!strcmp(s, "fscache")) { + version = CACHE_SC_FSCACHE; + p9_debug(P9_DEBUG_9P, "Cache mode: fscache\n"); + } else if (!strcmp(s, "mmap")) { + version = CACHE_SC_MMAP; + p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n"); + } else if (!strcmp(s, "readahead")) { + version = CACHE_SC_READAHEAD; + p9_debug(P9_DEBUG_9P, "Cache mode: readahead\n"); + } else if (!strcmp(s, "none")) { + version = CACHE_SC_NONE; + p9_debug(P9_DEBUG_9P, "Cache mode: none\n"); + } else if (kstrtoint(s, 0, &version) != 0) { + version = -EINVAL; + pr_info("Unknown Cache mode or invalid value %s\n", s); + } + return version; +} + /* * Display the mount options in /proc/mounts. */ @@ -269,8 +287,10 @@ int v9fs_parse_param(struct fs_context *fc, struct fs_parameter *param) #endif break; case Opt_cache: - session_opts->cache = result.uint_32; - p9_debug(P9_DEBUG_9P, "Cache mode: %s\n", param->string); + r = get_cache_mode(param->string); + if (r < 0) + return r; + session_opts->cache = r; break; case Opt_access: s = param->string;