From: Mark Brown <broonie@kernel.org>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>, Kees Cook <kees@kernel.org>,
Kees Cook <kees+treewide@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the ntfs tree with the origin tree
Date: Tue, 15 Sep 2026 13:06:10 +0100 [thread overview]
Message-ID: <aqk0suRfSCjoZ3KW@sirena.org.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 5488 bytes --]
Hi all,
Today's linux-next merge of the ntfs tree got a conflict in:
fs/ntfs/mft.c
between commit:
3a2c4d55e32ad ("treewide: refresh kmalloc_obj() conversions")
from the origin tree and commits:
107857fee6272 ("ntfs: write MFT folios through mapped I/O units")
9ed2f188c8875 ("ntfs: write MFT records through containing I/O units")
from the ntfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --cc fs/ntfs/mft.c
index 98ab686a5ea2f,c565bec49c7dd..0000000000000
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@@ -2634,42 -3174,96 +3174,97 @@@ static int ntfs_write_mft_block(struct
struct inode *vi = mapping->host;
struct ntfs_inode *ni = NTFS_I(vi);
struct ntfs_volume *vol = ni->vol;
- u8 *kaddr;
- struct ntfs_inode **locked_nis __free(kfree) =
- kmalloc_array(PAGE_SIZE / NTFS_BLOCK_SIZE,
- sizeof(struct ntfs_inode *), GFP_NOFS);
- struct inode **ref_inos __free(kfree) = kmalloc_array(
- PAGE_SIZE / NTFS_BLOCK_SIZE, sizeof(struct inode *), GFP_NOFS);
+ struct ntfs_inode **locked_nis __free(kfree) = kmalloc_objs(struct ntfs_inode *,
+ PAGE_SIZE / NTFS_BLOCK_SIZE,
+ GFP_NOFS);
- int nr_locked_nis = 0, err = 0, mft_ofs, prev_mft_ofs;
+ struct inode **ref_inos __free(kfree) = kmalloc_objs(struct inode *,
+ PAGE_SIZE / NTFS_BLOCK_SIZE,
+ GFP_NOFS);
- int nr_ref_inos = 0;
- struct bio *bio = NULL;
- u64 mft_no;
- struct ntfs_inode *tni;
- s64 lcn;
- s64 vcn = ntfs_pidx_to_cluster(vol, folio->index);
- s64 end_vcn = ntfs_bytes_to_cluster(vol, ni->allocated_size);
- unsigned int folio_sz;
- loff_t i_size = i_size_read(vi);
+ struct ntfs_mft_io_unit *units __free(kfree) = NULL;
+ struct bio *parent = NULL, *child = NULL;
+ struct ntfs_mft_write_ctx *ctx = NULL;
+ u8 *kaddr = NULL;
+ DECLARE_BITMAP(record_selected, PAGE_SIZE / NTFS_BLOCK_SIZE) = {};
+ u64 folio_byte, file_limit, folio_end, mirror_size;
+ unsigned int nr_records, nr_units = 0, max_units;
+ unsigned int nr_locked_nis = 0, nr_ref_inos = 0;
+ unsigned int record, unit_idx;
+ unsigned long flags;
+ loff_t i_size;
+ s64 allocated_size;
+ bool defer = false, redirty = false;
+ int err = 0;
- ntfs_debug("Entering for inode 0x%llx, attribute type 0x%x, folio index 0x%lx.",
- ni->mft_no, ni->type, folio->index);
+ read_lock_irqsave(&ni->size_lock, flags);
+ i_size = i_size_read(vi);
+ allocated_size = ni->allocated_size;
+ read_unlock_irqrestore(&ni->size_lock, flags);
- if (!locked_nis || !ref_inos) {
- folio_redirty_for_writepage(wbc, folio);
- folio_unlock(folio);
- return -ENOMEM;
+ ntfs_debug("Entering for inode 0x%llx, folio index 0x%lx.", ni->mft_no,
+ folio->index);
+ WARN_ON(!folio_test_locked(folio));
+
+ folio_byte = folio_pos(folio);
+ folio_end = folio_byte + PAGE_SIZE;
+ mirror_size = (u64)vol->mftmirr_size * vol->mft_record_size;
+
+ if (i_size <= folio_byte)
+ folio_zero_segment(folio, 0, PAGE_SIZE);
+ else if ((u64)i_size < folio_end)
+ folio_zero_segment(folio, i_size - folio_byte, PAGE_SIZE);
+
+ file_limit = min_t(u64, i_size, allocated_size);
+ nr_records = PAGE_SIZE / vol->mft_record_size;
+ max_units = PAGE_SIZE / min(vol->cluster_size, vol->mft_record_size);
+ units = kmalloc_array(max_units, sizeof(*units), GFP_NOFS);
+ if (!locked_nis || !ref_inos || !units) {
+ err = -ENOMEM;
+ goto out_noio;
}
- /* We have to zero every time due to mmap-at-end-of-file. */
- if (folio->index >= (i_size >> folio_shift(folio)))
- /* The page straddles i_size. */
- folio_zero_segment(folio,
- offset_in_folio(folio, i_size),
- folio_size(folio));
+ kaddr = kmap_local_folio(folio, 0);
+ folio_clear_uptodate(folio);
- lcn = lcn_from_index(vol, ni, folio->index);
- if (lcn <= LCN_HOLE) {
+ for (record = 0; record < nr_records; record++) {
+ struct ntfs_inode *tni = NULL;
+ struct inode *ref_vi = NULL;
+ u64 record_byte =
+ folio_byte + (u64)record * vol->mft_record_size;
+ u64 mft_no;
+
+ if (record_byte >= file_limit)
+ continue;
+ mft_no = record_byte >> vol->mft_record_size_bits;
+ if (!ntfs_may_write_mft_record(
+ vol, mft_no,
+ (struct mft_record *)(kaddr +
+ record * vol->mft_record_size),
+ &tni, &ref_vi)) {
+ if (ref_vi)
+ ref_inos[nr_ref_inos++] = ref_vi;
+ continue;
+ }
+ if (ref_vi)
+ ref_inos[nr_ref_inos++] = ref_vi;
+ if (tni) {
+ locked_nis[nr_locked_nis++] = tni;
+ if (tni->nr_extents < 0 &&
+ tni->ext.base_ntfs_ino == NTFS_I(vol->mft_ino))
+ continue;
+ }
+ __set_bit(record, record_selected);
+ }
+
+ err = ntfs_prepare_mft_folio_units(ni, folio_byte, file_limit,
+ record_selected, units, &nr_units,
+ max_units, &defer);
+ if (err)
+ goto out_noio;
+ if (!nr_units) {
+ if (defer)
+ goto out_noio;
+ folio_mark_uptodate(folio);
+ kunmap_local(kaddr);
folio_start_writeback(folio);
folio_unlock(folio);
folio_end_writeback(folio);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
reply other threads:[~2026-09-15 12:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aqk0suRfSCjoZ3KW@sirena.org.uk \
--to=broonie@kernel.org \
--cc=hyc.lee@gmail.com \
--cc=kees+treewide@kernel.org \
--cc=kees@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®