From nobody Sat Jun 13 01:33:42 2026 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95F7C2D8376 for ; Mon, 11 May 2026 16:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778515597; cv=none; b=Fmf5esBlp95jePEW5evwHMqq5xtPSxrGdMQRLZ65APjZpGw0uF8sBuhopIMwWs9HP3eILKXuOf+8I/mkLjU3uG1ymobfnCeWnSis4lXfYqBfm4S9cwPBe3ZAAiEAA1mC/Yut8QBAZ/mQPg83qkPkwpFMCzQ81DQ84835NPsDGCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778515597; c=relaxed/simple; bh=O7vxKwK4Frz7hw3ZsessBjAsAnJnPJnx/DkxIn7A+M4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JzHtLc/XoHD+91uWZ/G84zytH24GXmRXApZmeOvv+30jIoS/CJ/c1A8QpWH3PUdM7eYP7I/3AXkvkkQe+F7xjsaqMKfdXBsBcG5AZ5Ur1r1YINEmDZpc/Q0D1lm+v2McLogt7OsDEdGO02vwwm2BlsGKfjJOPGuPjZxXmq0F0mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cv5idmbU; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cv5idmbU" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-c70e3eb3af1so173326a12.2 for ; Mon, 11 May 2026 09:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778515593; x=1779120393; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DGyckoWlKcj/g+dvE3DVtCFjUKqFutWWvhlGNP+u3/Y=; b=cv5idmbUvwwbsLar+rJ+v0orLgJTCjLfgcHPDdRDEFretshVL1lbVBejHNm3+Wt1Y2 CJvjyrcWOTe+opE6bE4C0Q/OQeBpN4FMR6NZjGukEQtjB2ljJZVjePxX5DIdaYo+yNxc Gb09LpHs6SqRb1Ph2oeGqnNpnUwBxpqLLXObN0R23m+MwzgSDCP06vfO8WnPJM4y5cLq Qu3gBruJWTk+kVOQbxW2nGD/3YpwOOrDtljOnCUDccYfLV6prSJjCs5SYfvZqHSgVrT6 Pn0TcDoDXi7fFYTvT+Lbhwof6NImX4eUPk6AnLZ6Ts0ICTYALm6lWbzVS+A+C43LtZDe ernA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778515593; x=1779120393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DGyckoWlKcj/g+dvE3DVtCFjUKqFutWWvhlGNP+u3/Y=; b=RSdAHd1VTlcVib9HuF6cKo9nKLIzyi1wdlGZUzJTXLvVF0PbVvqEaT2am9GZJnHyqU i1fl4iKwN+BNqk7fmnPPXgew8OmvTxl1C/YYRS+rf86gKm+pl+yMXZAXJ1bK90ltwEUR IitOGTgcrIjYulJ4QvEQ7KJeOZSqLFDpLHnFlMQtncUBQh1knreY9WD0l3+2rOm3CAZL 1u7I2Gy4ytT6KJnw4V4u4Z80GXqEfoL7h0OuSK5cvzVwZlOS2YFcrCQ5tRowavR5EiVB zZ5bNp+Zf5PpNHG7jijSYau5/BvqF2v+6bKwomSb3mITBZzh8gWdWEJllkZQ5GHZ4FGp D91g== X-Forwarded-Encrypted: i=1; AFNElJ+hZB2DzUBuBBTEd0q4JkfTI7BZNUm6FECyfxHhK6ZWNRJA0eAO13L2wBwn6V7YnYZ2PV2iDGHjrtsZ1Gs=@vger.kernel.org X-Gm-Message-State: AOJu0YzgqprZmeW3+z7eP1T8wEAvV3IbFzBL+ciDn9DpN4W5H0yzHGmU uT55aFtZDWjtyu5T5p6wDRwfr66AYGB3p7+3XMbls8epOi7bpxA/RG/5 X-Gm-Gg: Acq92OG5vKEFm5dAf4Ga1U+UlgV3IWKnLl07Wchv3219VLuCNuh8XPEDP6LA5rdWBdq ftwDacuFJF+M4UewJzWAfplQCzZ3f9NVF6T0bYyc7xfKKlQKWflpI3W2j67Ts5PSb7wM8IWN/ND vi4yWX1zTY8vIbYSKVJQJYDItk7uSmL7W85XTsrkS9oTf7dhnHOSkC++oaXwgXUyzy5MFYEkeVZ U3DWTjUl3ezK1XiXMulNsYBTGHqRB/VKUzAg4pGLeHe5XlKQWIERQuZjUZ+PBh4V1KckLfJPHpN Fpc1MU54do7XzLNYv2w8cd5ZEaPikKrrdrZPLLHnsjy7+s/GwIca6gMLxqLrvrG+AOhsD6LAbeM cVnPCMEopDt0pzy2NEh6M8eRv/c4PS8w51Kb/GSKibLHi45gpQg+XJwhGrj2RoDeBjuTm5dT9qz kd7YcORdX3P0+dYE6FYGh4OYDPhA8= X-Received: by 2002:a17:902:d2cb:b0:2b2:aa7b:b3bd with SMTP id d9443c01a7336-2ba7f425857mr135549775ad.6.1778515593031; Mon, 11 May 2026 09:06:33 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e35ebesm112447045ad.43.2026.05.11.09.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 09:06:32 -0700 (PDT) From: DaeMyung Kang To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 1/3] ntfs: return view index entry data from lookup Date: Tue, 12 May 2026 01:06:23 +0900 Message-ID: <20260511160626.1268612-2-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511160626.1268612-1-charsyam@gmail.com> References: <20260511160626.1268612-1-charsyam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ntfs_index_lookup() always exposes the matched entry key through icx->data. That is correct for file name indexes, where $I30 callers expect the key to be a struct file_name_attr and update it in place. NTFS view indexes store a separate value in index_entry.data.vi. For example, $Quota/$Q uses the owner_id as the key and stores the quota_control_entry in the entry value. Returning the key makes quota code see only the 4-byte owner_id instead of the quota control entry. Preserve the existing $FILE_NAME index behavior, but return the entry value for view indexes. Use the index root type for that layout decision: indexes with ir->type =3D=3D AT_FILE_NAME expose the entry key, while view indexes have type 0 and expose the entry value through data.vi. Validate the value offset and length before exposing the pointer, and clear icx->data when the key is not found because the context then describes an insertion point rather than a matched value. Use unsigned arithmetic for the minimum data offset check, account for the VCN stored at the end of INDEX_ENTRY_NODE entries, and clear the returned context pointers before returning an entry-data validation error. Move the matched-entry data exposure and validation into a small helper, ntfs_index_lookup_set_data(), so the done label stays flat and the bounds check has a single return. Signed-off-by: DaeMyung Kang Reviewed-by: Hyunchul Lee --- fs/ntfs/index.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++-= -- fs/ntfs/index.h | 3 +- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c index a547bdc..30dfcbb 100644 --- a/fs/ntfs/index.c +++ b/fs/ntfs/index.c @@ -696,6 +696,53 @@ static int ntfs_icx_parent_dec(struct ntfs_index_conte= xt *icx) } /* + * ntfs_index_lookup_set_data - populate icx->data for the matched entry + * + * For directory $FILE_NAME indexes the caller updates the key in place, so + * expose the key. For view indexes the value lives at data.vi; validate + * its offset and length before exposing the pointer. Return 0 on success, + * or -EIO if the entry value is out of bounds. + */ +static int ntfs_index_lookup_set_data(struct ntfs_index_context *icx, + struct index_root *ir, + struct index_entry *ie) +{ + u16 data_len, data_off, entry_len, found_key_len; + unsigned int data_end, min_data_off; + + if (ie->flags & INDEX_ENTRY_END) + return -EIO; + + found_key_len =3D le16_to_cpu(ie->key_length); + if (ir->type =3D=3D AT_FILE_NAME) { + icx->data =3D (u8 *)ie + offsetof(struct index_entry, key); + icx->data_len =3D found_key_len; + return 0; + } + + entry_len =3D le16_to_cpu(ie->length); + data_off =3D le16_to_cpu(ie->data.vi.data_offset); + data_len =3D le16_to_cpu(ie->data.vi.data_length); + data_end =3D entry_len; + if (ie->flags & INDEX_ENTRY_NODE) { + /* The trailing child VCN is not part of the entry value. */ + if (data_end < sizeof(s64)) + return -EIO; + data_end -=3D sizeof(s64); + } + + min_data_off =3D offsetof(struct index_entry, key) + found_key_len; + if (data_off < min_data_off || data_off > data_end) + return -EIO; + if (data_len > data_end - data_off) + return -EIO; + + icx->data =3D (u8 *)ie + data_off; + icx->data_len =3D data_len; + return 0; +} + +/* * ntfs_index_lookup - find a key in an index and return its index entry * @key: key for which to search in the index * @key_len: length of @key in bytes @@ -710,7 +757,8 @@ static int ntfs_icx_parent_dec(struct ntfs_index_contex= t *icx) * If the @key is found in the index, 0 is returned and @icx is setup to * describe the index entry containing the matching @key. @icx->entry is = the * index entry and @icx->data and @icx->data_len are the index entry data = and - * its length in bytes, respectively. + * its length in bytes, respectively. For file name indexes @icx->data po= ints + * to the entry key; for view indexes @icx->data points to the entry value. * * If the @key is not found in the index, -ENOENT is returned and * @icx is setup to describe the index entry whose key collates immediately @@ -836,11 +884,30 @@ err_out: return err; done: icx->entry =3D ie; - icx->data =3D (u8 *)ie + offsetof(struct index_entry, key); - icx->data_len =3D le16_to_cpu(ie->key_length); + if (err) { + /* When the key is not found, ie is an insertion point. */ + icx->data =3D NULL; + icx->data_len =3D 0; + ntfs_debug("Done.\n"); + return err; + } + err =3D ntfs_index_lookup_set_data(icx, ir, ie); + if (err) { + ntfs_error(sb, + "Index entry data out of bounds in inode 0x%llx.", + (unsigned long long)ni->mft_no); + icx->entry =3D NULL; + icx->data =3D NULL; + icx->data_len =3D 0; + if (!icx->is_in_root) { + kvfree(ib); + ib =3D NULL; + icx->ib =3D NULL; + } + goto err_out; + } ntfs_debug("Done.\n"); return err; - } static struct index_block *ntfs_ib_alloc(s64 ib_vcn, u32 ib_size, diff --git a/fs/ntfs/index.h b/fs/ntfs/index.h index e68d6fa..4b8c5c8 100644 --- a/fs/ntfs/index.h +++ b/fs/ntfs/index.h @@ -58,7 +58,8 @@ * To obtain a context call ntfs_index_ctx_get(). * * We use this context to allow ntfs_index_lookup() to return the found in= dex * @entry and its @data without having to allocate a buffer and copy the @= entry - * and/or its @data into it. + * and/or its @data into it. For file name indexes @data points to the en= try + * key; for view indexes @data points to the entry value. * * When finished with the @entry and its @data, call ntfs_index_ctx_put() = to * free the context and other associated resources. -- 2.43.0 From nobody Sat Jun 13 01:33:42 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AD1036F42D for ; Mon, 11 May 2026 16:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778515599; cv=none; b=n5InlqEWDIkF7+E0r7scawVDDWVw51CYDu7hgZCj8CSV7POeG3OSuNsLJ5mRwTCuD1o853pIuDKBcVQSr/Wn3PNhrMax0psueaUDUnxsSGM8RK/y0Ro1FGNy5EpkKPaVuDNRQWLvNM5b5aY+V3KRProDtDPCcf115CrCtan/nls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778515599; c=relaxed/simple; bh=ecIkuWz1WdckEtCiOyNKqYp5k/6uevV7IZoOGIaC+Io=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rE83ReOvbEeoNeVF3Gc4AvJWJKaCTF4EKdBwM3mjCttQW+x8EAj5uaZ0FYvpPb454mSJcSFXVm7YnikBr/l7rFu8kHd6l3m61b72aFMTeVTasiyyjaf99UUpcWEhcdyns3WiyLdvQWbzGD6UjutjhZ7bF9nPCyPnSmA+0ZQ+EL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Sj27m9xk; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sj27m9xk" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2bcdc085c52so700325ad.1 for ; Mon, 11 May 2026 09:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778515596; x=1779120396; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fKIEyVTOjNsitHjzdLNLGjGFwGiysddgidr+ueXhPgU=; b=Sj27m9xkDD25Dv1XtVL8m9g6flNyqETkzq03YFtAVWo3CyR8Xuju1owxjvrIlZo5au Xg2Sm5UlqWMRYOirY+ZDJiLkvF1FFYkCaRt9sEn9ajAlYt2oPAbQ/kJYnyY5IieZHo1H pF3HAnQMekwY1PUo2N2pkiRhhQlb+8IzmEbWuvwh0d6vjyJjGjm7c8kHEAbXSpPQUELP hsNPFbAnUARG9hvgDJiy3XYSsETCWr2jo+CGng4X6fyEsu4ZAvMRjYDkSsPs/Zy/sYtI cwKJirF1oW9OSvMlYEjZ1QY+zohvsurTRd74HAHBgp0S8Ot551kiUUCGdQzWX/G1avab xXJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778515596; x=1779120396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fKIEyVTOjNsitHjzdLNLGjGFwGiysddgidr+ueXhPgU=; b=XTOomKGVlhXB2qKjSZhfh4XRfJM5zxoCNCro8EXApZ3QcSIrjOTGhIvJN7pMJQMhvx 7djhq85Z6f83+61KaUSIzlTwQM0AH8IC1ZKp4iPauqp2t/hxh0sNC4UKLQyRoQE4nV+6 Jz3co84x/mCDZJxvHy0vuq4jVc1RfnK89n/rC8srq8dq+yULDZ71//02cKsI0cNPw5ed NwltfkppxhZ/kL2zRnz1cieOe0/uImOy8hCvflWaqo9eAbOYn44IyspR+Qms8gdAYKwh fRYGBoPZVkXQfB+ieSbZuEWzIIfr1r4EC0qRNrht6X4YGgTfClXq3v9w972Gt8w8sB+A B49Q== X-Forwarded-Encrypted: i=1; AFNElJ99KA/VLThlOzsbvlWlxQTlf/eJ1RheTFt1eVkMNUjYumk+pHtUKMMJqXisnQeQG1YP8Vdt5YiTmp7mprs=@vger.kernel.org X-Gm-Message-State: AOJu0YzzvsB7ICyv9ke3KgJCd1Sk6ckgHMg/e67BPMCyySDqaqLni8Qh bIEFLR5BsGZ+4qUi3xfcZyI1i2GSPpuo88ybL3rWMYuLDcimAWqNyw3SB8JH3Q== X-Gm-Gg: Acq92OHgJ0doNaf5VOzEqxVxIjRnkhURfUbnoVv6JJSk0ZNFdKFbwWOgIA9F0ltZM6j MrT+4g8IoMvG6/AuDmUqY5KOnt6MFDCxiyVaPmrWtFjzoVmMXUKTrRkVDYU6Wkx59oZkvHbi7Rn +zRa5jjRzXMIjyDIGm7Z5lqLpiFEq/oOOEldLKe/6lMCMoDylA56AwDeHjQbwS7kPvekrrxNqWq gAkd6cX30e+oGuPVK+OONImVrqD1wbf+eilT6EKwF4LZEIIw5dRpAC6uzMOTmaWJ2uSptEXO9uw xjNdPxfz4JBcpoRuVk928LgxL0krjI6R4E3KyYc+b04MuqyNUSIk9yreKec//DsPUW3aynSiP4T WgSBBLBXBc9g3MqQ5J1t3evnLyn1lthgKWb0fv5wdxA06hUCazYdJ8mZ9b3ovdC6o5PmsnyFn12 RQTENxLj1NpJIJJENt X-Received: by 2002:a17:903:40d2:b0:2ba:7662:805d with SMTP id d9443c01a7336-2ba7b21d4f4mr130591975ad.2.1778515596306; Mon, 11 May 2026 09:06:36 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e35ebesm112447045ad.43.2026.05.11.09.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 09:06:36 -0700 (PDT) From: DaeMyung Kang To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 2/3] ntfs: use $Q when marking quotas out of date Date: Tue, 12 May 2026 01:06:24 +0900 Message-ID: <20260511160626.1268612-3-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511160626.1268612-1-charsyam@gmail.com> References: <20260511160626.1268612-1-charsyam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ntfs_mark_quotas_out_of_date() operates on vol->quota_q_ino, which is the $Quota/$Q index inode opened by load_and_init_quota(). However, it creates the index context with the $I30 name. That asks the $Quota file for an $INDEX_ROOT named $I30 and fails before the quota defaults entry can be looked up. Use the $Q index name when marking quotas out of date. Signed-off-by: DaeMyung Kang --- fs/ntfs/quota.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/quota.c b/fs/ntfs/quota.c index b443243..7086951 100644 --- a/fs/ntfs/quota.c +++ b/fs/ntfs/quota.c @@ -21,6 +21,7 @@ bool ntfs_mark_quotas_out_of_date(struct ntfs_volume *vol) { struct ntfs_index_context *ictx; struct quota_control_entry *qce; + static __le16 Q[3] =3D { cpu_to_le16('$'), cpu_to_le16('Q'), 0 }; const __le32 qid =3D QUOTA_DEFAULTS_ID; int err; =20 @@ -32,7 +33,7 @@ bool ntfs_mark_quotas_out_of_date(struct ntfs_volume *vol) return false; } inode_lock(vol->quota_q_ino); - ictx =3D ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino), I30, 4); + ictx =3D ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino), Q, 2); if (!ictx) { ntfs_error(vol->sb, "Failed to get index context."); goto err_out; --=20 2.43.0 From nobody Sat Jun 13 01:33:42 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49B0842B728 for ; Mon, 11 May 2026 16:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778515605; cv=none; b=Ly20VqLWZrm8+xHtuGKJara0TOyYhbnYdt6AYPLT5sSv6vaG0nDFmYc8oIU6Tg0GGLRmpSesTjCHIg/CYZICGSV87297hP++CIWMJPUDNm3uZ7zUyzZAuvv/OyFdVyM3lbtjbJsVr1mAeGVkSYZhajlY7KYQd30gBYG9T9eHmoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778515605; c=relaxed/simple; bh=+J6fOs6RknJ3UJj+/3CaRW5nRW9JX3hT5h97wmxwpv8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YHIBKEkM/dBCFhvoJTjYevZ51kcZ/xNYX4BMrK9q2pKioHLSUzv/g3QFGnNF9ZfJTFHw52VsqG3PFM8/FCA3VD+9Y7fOKpulI5IfBkV8pZGlEDAvGxCyPjAhMVQR3KgX3KQq9OEwTD5qAoKSyV61rbDgkkEMcy18ZoK5PL/WQwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CX3bgWnv; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CX3bgWnv" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2ba21e7fb97so2344095ad.0 for ; Mon, 11 May 2026 09:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778515603; x=1779120403; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2/puMZSjUUllHf9o6XXc/pt8PdxjFPmBhA/JoyPIRWU=; b=CX3bgWnvUcZzq2W2ljEhyilgbJUVFZMd5s57lIFJrq/7Ve2F0j5vxa/C9Cvzu/CFrj YpA5wVXG0lmKvmfBTFIOw+6XlLE1fX1jLeBdG57E2QKnnI23BSHLr7Dsjo+bpFuRWeYQ RiwFKK4e31OZ6oEA01ZX9ja3WkRsI9iWVWwUggXKrz49TrOz/Br5UBQEqx9o60xLLFs8 vNUA1RYws7QP97wz42uOlMd1E8o6Rf1r3B9VporEskUVDVzqzptXr+Y1ubijOfCxOyyB G+NJweIc6TWq/F/5pTq5/K3EQLVGIxjs84vrM8dFLhdzR9JmO63CcQyRzRtlLKotQv2A h3xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778515603; x=1779120403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2/puMZSjUUllHf9o6XXc/pt8PdxjFPmBhA/JoyPIRWU=; b=ot/cjbZEYA7qydh3Casl5nal5VHBnd1RKdc/2hkVtT0XV7SMwYROdNqgfCnIeaWwhE 7NAXwYCEiGSNV6V6noYc1Zi2gzQT1RjMrinCvs0o/jtXToegPWAstEyuLLwd//imNqQN doU6/eBckxmLn0ZjqWNwqioKEeuAKihFZoLrYKgv3moxmw/awURxU6Kmg4QqmgN3GTqs wUEqlVIqGYjLIjQqi4q/3W1527jr7QfNRVgRHTcnS43iy5nDzlSiwSWiaPCmQIfLWcG9 wIMX8NGgAL/m/WwmDCZJarVQMVzW3dlmzQNbhn9wClF8vJmHdagC/SExby0GVND5hwLO Jhvw== X-Forwarded-Encrypted: i=1; AFNElJ+x8v5XLAqoo5iXsyZ7i/jNecezIkAH6quYOcEuiAG0z0rJ4MCuvWaP8YbnbAEQIA1acXNSlFczMiieSPE=@vger.kernel.org X-Gm-Message-State: AOJu0YzEYsRPKdxHFZN1bnO/PxAO5G566YnbipCpHnOnQ7Shk1qlYwp4 FoDmZTzOXAtaQgfe05ZyuMgsacCyd9aCU08UI9sc4y7cPMfciSkK9TQc X-Gm-Gg: Acq92OFz+D03k8ZAQMG8qQkNPbIS9IJt5VLThkzJies50uohukJzXAh8oT2+L8UMeho cnTMKWpxCP7Oc8oIuvJLDVPWbYkQVT65clWqelBnUGCaiKheYtrGkwTc/IeAdu9QPempGhYGUoW IgpNMym4oi6rpA5UlOwVIbpHcYvthP+IavXXKRfjf0aO2iykLqr/LjvQayT/trj5gFcfNS8YeO6 pBLbiJpKtjGcjfC6GvzvPtv4NOyBYdCrfi5mUScF44ftywAlEhNkREwzOpza9ktrE4muH0m6y96 UsFOpCFe2wjqQXo6wSot9DB6QgvhZUlBn0fiI5KocrP/Y/nvRu+7G0DTqlGFEp6/kuQbRGPQFuj x2d8/cMgqmPyQSlZI0t11CMyHO8ORuHrlXDQ06RkjdX0AUNCWLXCrPIr3FUi1OZKAmiZdo8RZDX /on6WZUVF5XhYLUBYF X-Received: by 2002:a17:903:191:b0:2b2:67ca:5ffa with SMTP id d9443c01a7336-2ba7a599c68mr133831005ad.0.1778515603407; Mon, 11 May 2026 09:06:43 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e35ebesm112447045ad.43.2026.05.11.09.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 09:06:43 -0700 (PDT) From: DaeMyung Kang To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 3/3] ntfs: mark quotas out of date on initial rw mount Date: Tue, 12 May 2026 01:06:25 +0900 Message-ID: <20260511160626.1268612-4-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260511160626.1268612-1-charsyam@gmail.com> References: <20260511160626.1268612-1-charsyam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The remount read-write path marks quotas out of date after emptying the logfile, but initial read-write mount only loads $Quota and never calls ntfs_mark_quotas_out_of_date(). That leaves quota tracking metadata looking up to date even though the driver can modify the volume. Call the same helper after $Quota is loaded during initial read-write mount. If marking quotas out of date fails and the mount policy is on_errors=3Dremount-ro, convert the mount to read-only and set the volume error state, matching the nearby $Quota load failure handling. This intentionally follows the initial mount error policy rather than the remount-rw path, where a quota marking failure rejects the remount with -EROFS. Move the load/mark/policy handling into a small helper, ntfs_init_quota_for_mount(), which captures each call result in a local, derives the failure reason, and gates the read-only downgrade on policy in one place. This avoids calling helpers inside compound if conditions and keeps ntfs_load_system_files() flat. Signed-off-by: DaeMyung Kang --- fs/ntfs/super.c | 46 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 22dc786..8fa298f 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -1221,6 +1221,39 @@ static bool load_and_init_quota(struct ntfs_volume *= vol) return true; } +/* + * ntfs_init_quota_for_mount - finish quota setup at mount time + * @sb: super block of the volume being mounted + * @vol: ntfs volume to set up + * + * Load $Quota and, on a read-write mount, mark quotas out of date so that + * Windows rescans them on next boot. On failure, downgrade the mount to + * read-only when on_errors=3Dremount-ro, matching the volume error policy. + */ +static void ntfs_init_quota_for_mount(struct super_block *sb, + struct ntfs_volume *vol) +{ + bool quota_loaded, quota_marked =3D true; + const char *reason =3D NULL; + + quota_loaded =3D load_and_init_quota(vol); + if (quota_loaded && !sb_rdonly(sb)) + quota_marked =3D ntfs_mark_quotas_out_of_date(vol); + + if (!quota_loaded) + reason =3D "Failed to load $Quota"; + else if (!quota_marked) + reason =3D "Failed to mark quotas out of date"; + + if (!reason || vol->on_errors !=3D ON_ERRORS_REMOUNT_RO) + return; + + sb->s_flags |=3D SB_RDONLY; + ntfs_error(sb, "%s. Mounting read-only. Run chkdsk.", reason); + /* This will prevent a read-write remount. */ + NVolSetErrors(vol); +} + /* * load_and_init_attrdef - load the attribute definitions table for a volu= me * @vol: ntfs super block describing device whose attrdef to load @@ -1638,16 +1671,7 @@ get_ctx_vol_failed: ntfs_error(sb, "Failed to load $Extend."); goto iput_sec_err_out; } - /* Find the quota file, load it if present, and set it up. */ - if (!load_and_init_quota(vol) && - vol->on_errors =3D=3D ON_ERRORS_REMOUNT_RO) { - static const char *es1 =3D "Failed to load $Quota"; - static const char *es2 =3D ". Run chkdsk."; - - sb->s_flags |=3D SB_RDONLY; - ntfs_error(sb, "%s. Mounting read-only%s", es1, es2); - /* This will prevent a read-write remount. */ - NVolSetErrors(vol); - } + /* Find the quota file, load it if present, and set it up. */ + ntfs_init_quota_for_mount(sb, vol); return true; -- 2.43.0