ntfs: change mft_no type to u64

Changes the type of ntfs_inode::mft_no from unsigned long to u64
to safely handle the full 48-bit range without truncation risk, especially
in preparation for broader VFS inode number type (i_ino:u64) and to
improve consistency with ntfs driver practices.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Namjae Jeon 2026-03-05 10:40:54 +09:00
parent 5eed3d6aa5
commit d9038d99fb
10 changed files with 119 additions and 128 deletions

View File

@ -96,7 +96,7 @@ static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)
unsigned int delta;
unsigned char blocksize_bits;
ntfs_debug("Entering for mft_no 0x%lx, logical block 0x%llx.",
ntfs_debug("Entering for mft_no 0x%llx, logical block 0x%llx.",
ni->mft_no, (unsigned long long)block);
if (ni->type != AT_DATA || !NInoNonResident(ni) || NInoEncrypted(ni) ||
NInoMstProtected(ni)) {
@ -144,12 +144,12 @@ static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)
goto hole;
case LCN_ENOMEM:
ntfs_error(vol->sb,
"Not enough memory to complete mapping for inode 0x%lx. Returning 0.",
"Not enough memory to complete mapping for inode 0x%llx. Returning 0.",
ni->mft_no);
break;
default:
ntfs_error(vol->sb,
"Failed to complete mapping for inode 0x%lx. Run chkdsk. Returning 0.",
"Failed to complete mapping for inode 0x%llx. Run chkdsk. Returning 0.",
ni->mft_no);
break;
}

View File

@ -370,7 +370,7 @@ s64 ntfs_attr_vcn_to_lcn_nolock(struct ntfs_inode *ni, const s64 vcn,
unsigned long flags;
bool is_retry = false;
ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, %s_locked.",
ntfs_debug("Entering for i_ino 0x%llx, vcn 0x%llx, %s_locked.",
ni->mft_no, (unsigned long long)vcn,
write_locked ? "write" : "read");
if (!ni->runlist.rl) {
@ -521,7 +521,7 @@ struct runlist_element *ntfs_attr_find_vcn_nolock(struct ntfs_inode *ni, const s
int err = 0;
bool is_retry = false;
ntfs_debug("Entering for i_ino 0x%lx, vcn 0x%llx, with%s ctx.",
ntfs_debug("Entering for i_ino 0x%llx, vcn 0x%llx, with%s ctx.",
ni->mft_no, (unsigned long long)vcn, ctx ? "" : "out");
if (!ni->runlist.rl) {
read_lock_irqsave(&ni->size_lock, flags);
@ -679,8 +679,8 @@ static int ntfs_attr_find(const __le32 type, const __le16 *name,
if (a->name_length && ((le16_to_cpu(a->name_offset) +
a->name_length * sizeof(__le16)) >
le32_to_cpu(a->length))) {
ntfs_error(vol->sb, "Corrupt attribute name in MFT record %lld\n",
(long long)ctx->ntfs_ino->mft_no);
ntfs_error(vol->sb, "Corrupt attribute name in MFT record %llu\n",
ctx->ntfs_ino->mft_no);
break;
}
@ -790,7 +790,7 @@ int load_attribute_list(struct ntfs_inode *base_ni, u8 *al_start, const s64 size
attr_vi = ntfs_attr_iget(VFS_I(base_ni), AT_ATTRIBUTE_LIST, AT_UNNAMED, 0);
if (IS_ERR(attr_vi)) {
ntfs_error(base_ni->vol->sb,
"Failed to open an inode for Attribute list, mft = %ld",
"Failed to open an inode for Attribute list, mft = %llu",
base_ni->mft_no);
return PTR_ERR(attr_vi);
}
@ -798,7 +798,7 @@ int load_attribute_list(struct ntfs_inode *base_ni, u8 *al_start, const s64 size
if (ntfs_inode_attr_pread(attr_vi, 0, size, al_start) != size) {
iput(attr_vi);
ntfs_error(base_ni->vol->sb,
"Failed to read attribute list, mft = %ld",
"Failed to read attribute list, mft = %llu",
base_ni->mft_no);
return -EIO;
}
@ -817,7 +817,7 @@ int load_attribute_list(struct ntfs_inode *base_ni, u8 *al_start, const s64 size
break;
}
if (al != al_start + size) {
ntfs_error(base_ni->vol->sb, "Corrupt attribute list, mft = %ld",
ntfs_error(base_ni->vol->sb, "Corrupt attribute list, mft = %llu",
base_ni->mft_no);
return -EIO;
}
@ -890,7 +890,7 @@ static int ntfs_external_attr_find(const __le32 type,
int err = 0;
static const char *es = " Unmount and run chkdsk.";
ntfs_debug("Entering for inode 0x%lx, type 0x%x.", ni->mft_no, type);
ntfs_debug("Entering for inode 0x%llx, type 0x%x.", ni->mft_no, type);
if (!base_ni) {
/* First call happens with the base mft record. */
base_ni = ctx->base_ntfs_ino = ctx->ntfs_ino;
@ -1090,7 +1090,7 @@ static int ntfs_external_attr_find(const __le32 type,
if (MREF_LE(al_entry->mft_reference) == ni->mft_no) {
if (MSEQNO_LE(al_entry->mft_reference) != ni->seq_no) {
ntfs_error(vol->sb,
"Found stale mft reference in attribute list of base inode 0x%lx.%s",
"Found stale mft reference in attribute list of base inode 0x%llx.%s",
base_ni->mft_no, es);
err = -EIO;
break;
@ -1112,7 +1112,7 @@ static int ntfs_external_attr_find(const __le32 type,
al_entry->mft_reference), &ni);
if (IS_ERR(ctx->mrec)) {
ntfs_error(vol->sb,
"Failed to map extent mft record 0x%lx of base inode 0x%lx.%s",
"Failed to map extent mft record 0x%lx of base inode 0x%llx.%s",
MREF_LE(al_entry->mft_reference),
base_ni->mft_no, es);
err = PTR_ERR(ctx->mrec);
@ -1201,7 +1201,7 @@ static int ntfs_external_attr_find(const __le32 type,
if (!err) {
ntfs_error(vol->sb,
"Base inode 0x%lx contains corrupt attribute list attribute.%s",
"Base inode 0x%llx contains corrupt attribute list attribute.%s",
base_ni->mft_no, es);
err = -EIO;
}
@ -3497,7 +3497,7 @@ int ntfs_attr_update_mapping_pairs(struct ntfs_inode *ni, s64 from_vcn)
* delete extent) and continue search.
*/
if (finished_build) {
ntfs_debug("Mark attr 0x%x for delete in inode 0x%lx.\n",
ntfs_debug("Mark attr 0x%x for delete in inode 0x%llx.\n",
(unsigned int)le32_to_cpu(a->type), ctx->ntfs_ino->mft_no);
a->data.non_resident.highest_vcn = cpu_to_le64(NTFS_VCN_DELETE_MARK);
mark_mft_record_dirty(ctx->ntfs_ino);
@ -4728,7 +4728,7 @@ int ntfs_attr_map_cluster(struct ntfs_inode *ni, s64 vcn_start, s64 *lcn_start,
CASE_SENSITIVE, vcn, NULL, 0, ctx);
if (err) {
ntfs_error(vol->sb,
"ntfs_attr_lookup failed, ntfs inode(mft_no : %ld) type : 0x%x, err : %d",
"ntfs_attr_lookup failed, ntfs inode(mft_no : %llu) type : 0x%x, err : %d",
ni->mft_no, ni->type, err);
goto out;
}

View File

@ -797,7 +797,7 @@ int ntfs_read_compressed_block(struct folio *folio)
*/
if (err) {
ntfs_error(vol->sb,
"ntfs_decompress() failed in inode 0x%lx with error code %i. Skipping this compression block.",
"ntfs_decompress() failed in inode 0x%llx with error code %i. Skipping this compression block.",
ni->mft_no, -err);
/* Release the unfinished pages. */
for (; prev_cur_page < cur_page; prev_cur_page++) {
@ -823,7 +823,7 @@ int ntfs_read_compressed_block(struct folio *folio)
page = pages[cur_page];
if (page) {
ntfs_error(vol->sb,
"Still have pages left! Terminating them with extreme prejudice. Inode 0x%lx, page index 0x%lx.",
"Still have pages left! Terminating them with extreme prejudice. Inode 0x%llx, page index 0x%lx.",
ni->mft_no, page->__folio_index);
flush_dcache_page(page);
kunmap_local(page_address(page));

View File

@ -102,7 +102,7 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
if (unlikely(err)) {
if (err == -ENOENT) {
ntfs_error(sb,
"Index root attribute missing in directory inode 0x%lx.",
"Index root attribute missing in directory inode 0x%llx.",
dir_ni->mft_no);
err = -EIO;
}
@ -338,29 +338,29 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
/* Bounds checks. */
if ((u8 *)ia < kaddr || (u8 *)ia > kaddr + PAGE_SIZE) {
ntfs_error(sb,
"Out of bounds check failed. Corrupt directory inode 0x%lx or driver bug.",
"Out of bounds check failed. Corrupt directory inode 0x%llx or driver bug.",
dir_ni->mft_no);
goto unm_err_out;
}
/* Catch multi sector transfer fixup errors. */
if (unlikely(!ntfs_is_indx_record(ia->magic))) {
ntfs_error(sb,
"Directory index record with vcn 0x%llx is corrupt. Corrupt inode 0x%lx. Run chkdsk.",
(unsigned long long)vcn, dir_ni->mft_no);
"Directory index record with vcn 0x%llx is corrupt. Corrupt inode 0x%llx. Run chkdsk.",
vcn, dir_ni->mft_no);
goto unm_err_out;
}
if (le64_to_cpu(ia->index_block_vcn) != vcn) {
ntfs_error(sb,
"Actual VCN (0x%llx) of index buffer is different from expected VCN (0x%llx). Directory inode 0x%lx is corrupt or driver bug.",
(unsigned long long)le64_to_cpu(ia->index_block_vcn),
(unsigned long long)vcn, dir_ni->mft_no);
"Actual VCN (0x%llx) of index buffer is different from expected VCN (0x%llx). Directory inode 0x%llx is corrupt or driver bug.",
le64_to_cpu(ia->index_block_vcn),
vcn, dir_ni->mft_no);
goto unm_err_out;
}
if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
dir_ni->itype.index.block_size) {
ntfs_error(sb,
"Index buffer (VCN 0x%llx) of directory inode 0x%lx has a size (%u) differing from the directory specified size (%u). Directory inode is corrupt or driver bug.",
(unsigned long long)vcn, dir_ni->mft_no,
"Index buffer (VCN 0x%llx) of directory inode 0x%llx has a size (%u) differing from the directory specified size (%u). Directory inode is corrupt or driver bug.",
vcn, dir_ni->mft_no,
le32_to_cpu(ia->index.allocated_size) + 0x18,
dir_ni->itype.index.block_size);
goto unm_err_out;
@ -368,15 +368,15 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
index_end = (u8 *)ia + dir_ni->itype.index.block_size;
if (index_end > kaddr + PAGE_SIZE) {
ntfs_error(sb,
"Index buffer (VCN 0x%llx) of directory inode 0x%lx crosses page boundary. Impossible! Cannot access! This is probably a bug in the driver.",
(unsigned long long)vcn, dir_ni->mft_no);
"Index buffer (VCN 0x%llx) of directory inode 0x%llx crosses page boundary. Impossible! Cannot access! This is probably a bug in the driver.",
vcn, dir_ni->mft_no);
goto unm_err_out;
}
index_end = (u8 *)&ia->index + le32_to_cpu(ia->index.index_length);
if (index_end > (u8 *)ia + dir_ni->itype.index.block_size) {
ntfs_error(sb,
"Size of index buffer (VCN 0x%llx) of directory inode 0x%lx exceeds maximum size.",
(unsigned long long)vcn, dir_ni->mft_no);
"Size of index buffer (VCN 0x%llx) of directory inode 0x%llx exceeds maximum size.",
vcn, dir_ni->mft_no);
goto unm_err_out;
}
/* The first index entry. */
@ -393,7 +393,7 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
(u8 *)ie + sizeof(struct index_entry_header) > index_end ||
(u8 *)ie + sizeof(struct index_entry_header) + le16_to_cpu(ie->key_length) >
index_end || (u8 *)ie + le16_to_cpu(ie->length) > index_end) {
ntfs_error(sb, "Index entry out of bounds in directory inode 0x%lx.",
ntfs_error(sb, "Index entry out of bounds in directory inode 0x%llx.",
dir_ni->mft_no);
goto unm_err_out;
}
@ -546,7 +546,7 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
if (ie->flags & INDEX_ENTRY_NODE) {
if ((ia->index.flags & NODE_MASK) == LEAF_NODE) {
ntfs_error(sb,
"Index entry with child node found in a leaf node in directory inode 0x%lx.",
"Index entry with child node found in a leaf node in directory inode 0x%llx.",
dir_ni->mft_no);
goto unm_err_out;
}
@ -566,7 +566,7 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
kaddr = NULL;
goto descend_into_child_node;
}
ntfs_error(sb, "Negative child node vcn in directory inode 0x%lx.",
ntfs_error(sb, "Negative child node vcn in directory inode 0x%llx.",
dir_ni->mft_no);
goto unm_err_out;
}
@ -863,7 +863,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
/* Find the index root attribute in the mft record. */
if (ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, 0,
ctx)) {
ntfs_error(sb, "Index root attribute missing in directory inode %ld",
ntfs_error(sb, "Index root attribute missing in directory inode %llu",
ndir->mft_no);
ntfs_attr_put_search_ctx(ctx);
err = -ENOMEM;
@ -1062,8 +1062,8 @@ int ntfs_check_empty_dir(struct ntfs_inode *ni, struct mft_record *ni_mrec)
ret = ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
0, ctx);
if (ret) {
ntfs_error(ni->vol->sb, "Index root attribute missing in directory inode %lld",
(unsigned long long)ni->mft_no);
ntfs_error(ni->vol->sb, "Index root attribute missing in directory inode %llu",
ni->mft_no);
ntfs_attr_put_search_ctx(ctx);
return ret;
}

View File

@ -89,7 +89,7 @@ static int ntfs_init_locked_inode(struct inode *vi, void *data)
struct ntfs_attr *na = data;
struct ntfs_inode *ni = NTFS_I(vi);
vi->i_ino = na->mft_no;
vi->i_ino = (unsigned long)na->mft_no;
if (na->type == AT_INDEX_ALLOCATION)
NInoSetMstProtected(ni);
@ -149,7 +149,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi,
* Return the struct inode on success. Check the return value with IS_ERR() and
* if true, the function failed and the error code is obtained from PTR_ERR().
*/
struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
struct inode *ntfs_iget(struct super_block *sb, u64 mft_no)
{
struct inode *vi;
int err;
@ -500,7 +500,7 @@ void __ntfs_init_inode(struct super_block *sb, struct ntfs_inode *ni)
static struct lock_class_key extent_inode_mrec_lock_key;
inline struct ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
unsigned long mft_no)
u64 mft_no)
{
struct ntfs_inode *ni = ntfs_alloc_extent_inode();
@ -1451,9 +1451,9 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
err_out:
if (err != -ENOENT)
ntfs_error(vol->sb,
"Failed with error code %i while reading attribute inode (mft_no 0x%lx, type 0x%x, name_len %i). Marking corrupt inode and base inode 0x%lx as bad. Run chkdsk.",
err, vi->i_ino, ni->type, ni->name_len,
base_vi->i_ino);
"Failed with error code %i while reading attribute inode (mft_no 0x%llx, type 0x%x, name_len %i). Marking corrupt inode and base inode 0x%llx as bad. Run chkdsk.",
err, ni->mft_no, ni->type, ni->name_len,
base_ni->mft_no);
if (err != -ENOENT && err != -ENOMEM)
NVolSetErrors(vol);
return err;
@ -1709,8 +1709,8 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
unmap_mft_record(base_ni);
err_out:
ntfs_error(vi->i_sb,
"Failed with error code %i while reading index inode (mft_no 0x%lx, name_len %i.",
err, vi->i_ino, ni->name_len);
"Failed with error code %i while reading index inode (mft_no 0x%llx, name_len %i.",
err, ni->mft_no, ni->name_len);
if (err != -EOPNOTSUPP && err != -ENOMEM)
NVolSetErrors(vol);
return err;
@ -2244,7 +2244,7 @@ static void __ntfs_clear_inode(struct ntfs_inode *ni)
void ntfs_clear_extent_inode(struct ntfs_inode *ni)
{
ntfs_debug("Entering for inode 0x%lx.", ni->mft_no);
ntfs_debug("Entering for inode 0x%llx.", ni->mft_no);
WARN_ON(NInoAttr(ni));
WARN_ON(ni->nr_extents != -1);
@ -2580,7 +2580,7 @@ int ntfs_inode_sync_filename(struct ntfs_inode *ni)
int err = 0;
unsigned long flags;
ntfs_debug("Entering for inode %lld\n", (long long)ni->mft_no);
ntfs_debug("Entering for inode %llu\n", ni->mft_no);
ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx)
@ -2623,8 +2623,8 @@ int ntfs_inode_sync_filename(struct ntfs_inode *ni)
ictx = ntfs_index_ctx_get(index_ni, I30, 4);
if (!ictx) {
ntfs_error(sb, "Failed to get index ctx, inode %lld",
(long long)index_ni->mft_no);
ntfs_error(sb, "Failed to get index ctx, inode %llu",
index_ni->mft_no);
iput(index_vi);
mutex_unlock(&index_ni->mrec_lock);
continue;
@ -2632,8 +2632,8 @@ int ntfs_inode_sync_filename(struct ntfs_inode *ni)
err = ntfs_index_lookup(fn, sizeof(struct file_name_attr), ictx);
if (err) {
ntfs_debug("Index lookup failed, inode %lld",
(long long)index_ni->mft_no);
ntfs_debug("Index lookup failed, inode %llu",
index_ni->mft_no);
ntfs_index_ctx_put(ictx);
iput(index_vi);
mutex_unlock(&index_ni->mrec_lock);
@ -2679,8 +2679,8 @@ int ntfs_inode_sync_filename(struct ntfs_inode *ni)
}
/* Check for real error occurred. */
if (err != -ENOENT) {
ntfs_error(sb, "Attribute lookup failed, err : %d, inode %lld", err,
(long long)ni->mft_no);
ntfs_error(sb, "Attribute lookup failed, err : %d, inode %llu", err,
ni->mft_no);
} else
err = 0;
@ -2927,9 +2927,8 @@ static struct ntfs_inode *ntfs_extent_inode_open(struct ntfs_inode *base_ni,
return NULL;
sb = base_ni->vol->sb;
ntfs_debug("Opening extent inode %lld (base mft record %lld).\n",
(unsigned long long)mft_no,
(unsigned long long)base_ni->mft_no);
ntfs_debug("Opening extent inode %llu (base mft record %llu).\n",
mft_no, base_ni->mft_no);
/* Is the extent inode already open and attached to the base inode? */
if (base_ni->nr_extents > 0) {
@ -2942,7 +2941,7 @@ static struct ntfs_inode *ntfs_extent_inode_open(struct ntfs_inode *base_ni,
continue;
ni_mrec = map_mft_record(ni);
if (IS_ERR(ni_mrec)) {
ntfs_error(sb, "failed to map mft record for %lu",
ntfs_error(sb, "failed to map mft record for %llu",
ni->mft_no);
goto out;
}
@ -2950,8 +2949,8 @@ static struct ntfs_inode *ntfs_extent_inode_open(struct ntfs_inode *base_ni,
seq_no = MSEQNO_LE(mref);
if (seq_no &&
seq_no != le16_to_cpu(ni_mrec->sequence_number)) {
ntfs_error(sb, "Found stale extent mft reference mft=%lld",
(long long)ni->mft_no);
ntfs_error(sb, "Found stale extent mft reference mft=%llu",
ni->mft_no);
unmap_mft_record(ni);
goto out;
}
@ -3011,7 +3010,7 @@ int ntfs_inode_attach_all_extents(struct ntfs_inode *ni)
if (NInoAttr(ni))
ni = ni->ext.base_ntfs_ino;
ntfs_debug("Entering for inode 0x%llx.\n", (long long) ni->mft_no);
ntfs_debug("Entering for inode 0x%llx.\n", ni->mft_no);
/* Inode haven't got attribute list, thus nothing to attach. */
if (!NInoAttrList(ni))
@ -3057,7 +3056,7 @@ int ntfs_inode_add_attrlist(struct ntfs_inode *ni)
if (!ni)
return -EINVAL;
ntfs_debug("inode %llu\n", (unsigned long long) ni->mft_no);
ntfs_debug("inode %llu\n", ni->mft_no);
if (NInoAttrList(ni) || ni->nr_extents) {
ntfs_error(ni->vol->sb, "Inode already has attribute list");
@ -3122,8 +3121,8 @@ int ntfs_inode_add_attrlist(struct ntfs_inode *ni)
/* Check for real error occurred. */
if (err != -ENOENT) {
ntfs_error(ni->vol->sb, "%s: Attribute lookup failed, inode %lld",
__func__, (long long)ni->mft_no);
ntfs_error(ni->vol->sb, "%s: Attribute lookup failed, inode %llu",
__func__, ni->mft_no);
goto put_err_out;
}
@ -3244,7 +3243,7 @@ int ntfs_inode_close(struct ntfs_inode *ni)
if (!ni)
return 0;
ntfs_debug("Entering for inode %lld\n", (long long)ni->mft_no);
ntfs_debug("Entering for inode %llu\n", ni->mft_no);
/* Is this a base inode with mapped extent inodes? */
/*
@ -3282,8 +3281,8 @@ int ntfs_inode_close(struct ntfs_inode *ni)
}
if (NInoDirty(ni))
ntfs_error(ni->vol->sb, "Releasing dirty inode %lld!\n",
(long long)ni->mft_no);
ntfs_error(ni->vol->sb, "Releasing dirty inode %llu!\n",
ni->mft_no);
if (NInoAttrList(ni) && ni->attr_list)
kvfree(ni->attr_list);
ntfs_destroy_ext_inode(ni);
@ -3301,8 +3300,8 @@ void ntfs_destroy_ext_inode(struct ntfs_inode *ni)
ntfs_attr_close(ni);
if (NInoDirty(ni))
ntfs_error(ni->vol->sb, "Releasing dirty ext inode %lld!\n",
(long long)ni->mft_no);
ntfs_error(ni->vol->sb, "Releasing dirty ext inode %llu!\n",
ni->mft_no);
if (NInoAttrList(ni) && ni->attr_list)
kvfree(ni->attr_list);
kfree(ni->mrec);
@ -3366,8 +3365,7 @@ int ntfs_inode_free_space(struct ntfs_inode *ni, int size)
if (!ni || size < 0)
return -EINVAL;
ntfs_debug("Entering for inode %lld, size %d\n",
(unsigned long long)ni->mft_no, size);
ntfs_debug("Entering for inode %llu, size %d\n", ni->mft_no, size);
sb = ni->vol->sb;
ni_mrec = map_mft_record(ni);

View File

@ -100,7 +100,7 @@ struct ntfs_inode {
rwlock_t size_lock;
unsigned long state;
__le32 flags;
unsigned long mft_no;
u64 mft_no;
u16 seq_no;
atomic_t count;
struct ntfs_volume *vol;
@ -292,7 +292,7 @@ static inline struct inode *VFS_I(struct ntfs_inode *ni)
* possible on all architectures.
*/
struct ntfs_attr {
unsigned long mft_no;
u64 mft_no;
__le16 *name;
u32 name_len;
__le32 type;
@ -300,7 +300,7 @@ struct ntfs_attr {
};
int ntfs_test_inode(struct inode *vi, void *data);
struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no);
struct inode *ntfs_iget(struct super_block *sb, u64 mft_no);
struct inode *ntfs_attr_iget(struct inode *base_vi, __le32 type,
__le16 *name, u32 name_len);
struct inode *ntfs_index_iget(struct inode *base_vi, __le16 *name,
@ -320,8 +320,7 @@ static inline void ntfs_init_big_inode(struct inode *vi)
ni->mft_no = vi->i_ino;
}
struct ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
unsigned long mft_no);
struct ntfs_inode *ntfs_new_extent_inode(struct super_block *sb, u64 mft_no);
void ntfs_clear_extent_inode(struct ntfs_inode *ni);
int ntfs_read_inode_mount(struct inode *vi);
int ntfs_show_options(struct seq_file *sf, struct dentry *root);

View File

@ -842,7 +842,7 @@ s64 __ntfs_cluster_free(struct ntfs_inode *ni, const s64 start_vcn, s64 count,
int err;
unsigned int memalloc_flags;
ntfs_debug("Entering for i_ino 0x%lx, start_vcn 0x%llx, count 0x%llx.%s",
ntfs_debug("Entering for i_ino 0x%llx, start_vcn 0x%llx, count 0x%llx.%s",
ni->mft_no, start_vcn, count,
is_rollback ? " (rollback)" : "");
vol = ni->vol;

View File

@ -26,14 +26,14 @@
* Returns 0 if the checks are successful. If not, return -EIO.
*/
int ntfs_mft_record_check(const struct ntfs_volume *vol, struct mft_record *m,
unsigned long mft_no)
u64 mft_no)
{
struct attr_record *a;
struct super_block *sb = vol->sb;
if (!ntfs_is_file_record(m->magic)) {
ntfs_error(sb, "Record %llu has no FILE magic (0x%x)\n",
(unsigned long long)mft_no, le32_to_cpu(*(__le32 *)m));
mft_no, le32_to_cpu(*(__le32 *)m));
goto err_out;
}
@ -41,36 +41,33 @@ int ntfs_mft_record_check(const struct ntfs_volume *vol, struct mft_record *m,
(vol->mft_record_size >> NTFS_BLOCK_SIZE_BITS) + 1 != le16_to_cpu(m->usa_count) ||
le16_to_cpu(m->usa_ofs) + le16_to_cpu(m->usa_count) * 2 > vol->mft_record_size) {
ntfs_error(sb, "Record %llu has corrupt fix-up values fields\n",
(unsigned long long)mft_no);
mft_no);
goto err_out;
}
if (le32_to_cpu(m->bytes_allocated) != vol->mft_record_size) {
ntfs_error(sb, "Record %llu has corrupt allocation size (%u <> %u)\n",
(unsigned long long)mft_no,
vol->mft_record_size,
mft_no, vol->mft_record_size,
le32_to_cpu(m->bytes_allocated));
goto err_out;
}
if (le32_to_cpu(m->bytes_in_use) > vol->mft_record_size) {
ntfs_error(sb, "Record %llu has corrupt in-use size (%u > %u)\n",
(unsigned long long)mft_no,
le32_to_cpu(m->bytes_in_use),
mft_no, le32_to_cpu(m->bytes_in_use),
vol->mft_record_size);
goto err_out;
}
if (le16_to_cpu(m->attrs_offset) & 7) {
ntfs_error(sb, "Attributes badly aligned in record %llu\n",
(unsigned long long)mft_no);
mft_no);
goto err_out;
}
a = (struct attr_record *)((char *)m + le16_to_cpu(m->attrs_offset));
if ((char *)a < (char *)m || (char *)a > (char *)m + vol->mft_record_size) {
ntfs_error(sb, "Record %llu is corrupt\n",
(unsigned long long)mft_no);
ntfs_error(sb, "Record %llu is corrupt\n", mft_no);
goto err_out;
}
@ -125,7 +122,7 @@ static inline struct mft_record *map_mft_record_folio(struct ntfs_inode *ni)
vol->mft_record_size) {
folio = ERR_PTR(-ENOENT);
ntfs_error(vol->sb,
"Attempt to read mft record 0x%lx, which is beyond the end of the mft. This is probably a bug in the ntfs driver.",
"Attempt to read mft record 0x%llx, which is beyond the end of the mft. This is probably a bug in the ntfs driver.",
ni->mft_no);
goto err_out;
}
@ -192,7 +189,7 @@ struct mft_record *map_mft_record(struct ntfs_inode *ni)
if (!ni)
return ERR_PTR(-EINVAL);
ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no);
ntfs_debug("Entering for mft_no 0x%llx.", ni->mft_no);
/* Make sure the ntfs inode doesn't go away. */
atomic_inc(&ni->count);
@ -230,7 +227,7 @@ void unmap_mft_record(struct ntfs_inode *ni)
if (!ni)
return;
ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no);
ntfs_debug("Entering for mft_no 0x%llx.", ni->mft_no);
folio = ni->folio;
if (atomic_dec_return(&ni->count) > 1)
@ -258,11 +255,11 @@ struct mft_record *map_extent_mft_record(struct ntfs_inode *base_ni, u64 mref,
struct ntfs_inode *ni = NULL;
struct ntfs_inode **extent_nis = NULL;
int i;
unsigned long mft_no = MREF(mref);
u64 mft_no = MREF(mref);
u16 seq_no = MSEQNO(mref);
bool destroy_ni = false;
ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).",
ntfs_debug("Mapping extent mft record 0x%llx (base mft record 0x%llx).",
mft_no, base_ni->mft_no);
/* Make sure the base ntfs inode doesn't go away. */
atomic_inc(&base_ni->count);
@ -410,7 +407,7 @@ void __mark_mft_record_dirty(struct ntfs_inode *ni)
{
struct ntfs_inode *base_ni;
ntfs_debug("Entering for inode 0x%lx.", ni->mft_no);
ntfs_debug("Entering for inode 0x%llx.", ni->mft_no);
WARN_ON(NInoAttr(ni));
/* Determine the base vfs inode and mark it dirty, too. */
if (likely(ni->nr_extents >= 0))
@ -449,7 +446,7 @@ static void ntfs_bio_end_io(struct bio *bio)
*
* NOTE: We always perform synchronous i/o.
*/
int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const unsigned long mft_no,
int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const u64 mft_no,
struct mft_record *m)
{
u8 *kmirr = NULL;
@ -458,7 +455,7 @@ int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const unsigned long mft_no,
int err = 0;
struct bio *bio;
ntfs_debug("Entering for inode 0x%lx.", mft_no);
ntfs_debug("Entering for inode 0x%llx.", mft_no);
if (unlikely(!vol->mftmirr_ino)) {
/* This could happen during umount... */
@ -511,7 +508,7 @@ int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const unsigned long mft_no,
if (likely(!err)) {
ntfs_debug("Done.");
} else {
ntfs_error(vol->sb, "I/O error while writing mft mirror record 0x%lx!", mft_no);
ntfs_error(vol->sb, "I/O error while writing mft mirror record 0x%llx!", mft_no);
err_out:
ntfs_error(vol->sb,
"Failed to synchronize $MFTMirr (error code %i). Volume will be left marked dirty on umount. Run chkdsk on the partition after umounting to correct this.",
@ -547,7 +544,7 @@ int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int syn
struct bio *bio;
unsigned int offset = 0, folio_size;
ntfs_debug("Entering for inode 0x%lx.", ni->mft_no);
ntfs_debug("Entering for inode 0x%llx.", ni->mft_no);
WARN_ON(NInoAttr(ni));
WARN_ON(!folio_test_locked(folio));
@ -609,7 +606,7 @@ int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int syn
if (unlikely(err)) {
/* I/O error during writing. This is really bad! */
ntfs_error(vol->sb,
"I/O error while writing mft record 0x%lx! Marking base inode as bad. You should unmount the volume and run chkdsk.",
"I/O error while writing mft record 0x%llx! Marking base inode as bad. You should unmount the volume and run chkdsk.",
ni->mft_no);
goto err_out;
}
@ -734,7 +731,7 @@ static int ntfs_test_inode_wb(struct inode *vi, unsigned long ino, void *data)
* If we manage to obtain the lock we have exclusive access to the extent mft
* record. We set @locked_ni to the now locked ntfs inode and return 'true'.
*/
bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_no,
static bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const u64 mft_no,
const struct mft_record *m, struct ntfs_inode **locked_ni,
struct inode **ref_vi)
{
@ -745,7 +742,7 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
int i;
struct ntfs_attr na = {0};
ntfs_debug("Entering for inode 0x%lx.", mft_no);
ntfs_debug("Entering for inode 0x%llx.", mft_no);
/*
* Normally we do not return a locked inode so set @locked_ni to NULL.
*/
@ -756,7 +753,7 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
* Check if the inode corresponding to this mft record is in the VFS
* inode cache and obtain a reference to it if it is.
*/
ntfs_debug("Looking for inode 0x%lx in icache.", mft_no);
ntfs_debug("Looking for inode 0x%llx in icache.", mft_no);
na.mft_no = mft_no;
na.type = AT_UNUSED;
/*
@ -778,28 +775,28 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
return false;
}
if (vi) {
ntfs_debug("Base inode 0x%lx is in icache.", mft_no);
ntfs_debug("Base inode 0x%llx is in icache.", mft_no);
/* The inode is in icache. */
ni = NTFS_I(vi);
/* Take a reference to the ntfs inode. */
atomic_inc(&ni->count);
/* If the inode is dirty, do not write this record. */
if (NInoDirty(ni)) {
ntfs_debug("Inode 0x%lx is dirty, do not write it.",
ntfs_debug("Inode 0x%llx is dirty, do not write it.",
mft_no);
atomic_dec(&ni->count);
*ref_vi = vi;
return false;
}
ntfs_debug("Inode 0x%lx is not dirty.", mft_no);
ntfs_debug("Inode 0x%llx is not dirty.", mft_no);
/* The inode is not dirty, try to take the mft record lock. */
if (unlikely(!mutex_trylock(&ni->mrec_lock))) {
ntfs_debug("Mft record 0x%lx is already locked, do not write it.", mft_no);
ntfs_debug("Mft record 0x%llx is already locked, do not write it.", mft_no);
atomic_dec(&ni->count);
*ref_vi = vi;
return false;
}
ntfs_debug("Managed to lock mft record 0x%lx, write it.",
ntfs_debug("Managed to lock mft record 0x%llx, write it.",
mft_no);
/*
* The write has to occur while we hold the mft record lock so
@ -808,17 +805,17 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
*locked_ni = ni;
return true;
}
ntfs_debug("Inode 0x%lx is not in icache.", mft_no);
ntfs_debug("Inode 0x%llx is not in icache.", mft_no);
/* The inode is not in icache. */
/* Write the record if it is not a mft record (type "FILE"). */
if (!ntfs_is_mft_record(m->magic)) {
ntfs_debug("Mft record 0x%lx is not a FILE record, write it.",
ntfs_debug("Mft record 0x%llx is not a FILE record, write it.",
mft_no);
return true;
}
/* Write the mft record if it is a base inode. */
if (!m->base_mft_record) {
ntfs_debug("Mft record 0x%lx is a base record, write it.",
ntfs_debug("Mft record 0x%llx is a base record, write it.",
mft_no);
return true;
}
@ -829,7 +826,7 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
*/
na.mft_no = MREF_LE(m->base_mft_record);
na.state = 0;
ntfs_debug("Mft record 0x%lx is an extent record. Looking for base inode 0x%lx in icache.",
ntfs_debug("Mft record 0x%llx is an extent record. Looking for base inode 0x%llx in icache.",
mft_no, na.mft_no);
if (!na.mft_no) {
/* Balance the below iput(). */
@ -843,7 +840,7 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
if (!vi)
return false;
ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no);
ntfs_debug("Base inode 0x%llx is in icache.", na.mft_no);
/*
* The base inode is in icache. Check if it has the extent inode
* corresponding to this extent mft record attached.
@ -857,7 +854,7 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
*/
mutex_unlock(&ni->extent_lock);
*ref_vi = vi;
ntfs_debug("Base inode 0x%lx has no attached extent inodes, write the extent record.",
ntfs_debug("Base inode 0x%llx has no attached extent inodes, write the extent record.",
na.mft_no);
return true;
}
@ -880,11 +877,11 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
if (!eni) {
mutex_unlock(&ni->extent_lock);
*ref_vi = vi;
ntfs_debug("Extent inode 0x%lx is not attached to its base inode 0x%lx, write the extent record.",
ntfs_debug("Extent inode 0x%llx is not attached to its base inode 0x%llx, write the extent record.",
mft_no, na.mft_no);
return true;
}
ntfs_debug("Extent inode 0x%lx is attached to its base inode 0x%lx.",
ntfs_debug("Extent inode 0x%llx is attached to its base inode 0x%llx.",
mft_no, na.mft_no);
/* Take a reference to the extent ntfs inode. */
atomic_inc(&eni->count);
@ -904,11 +901,11 @@ bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const unsigned long mft_
if (unlikely(!mutex_trylock(&eni->mrec_lock))) {
atomic_dec(&eni->count);
*ref_vi = vi;
ntfs_debug("Extent mft record 0x%lx is already locked, do not write it.",
ntfs_debug("Extent mft record 0x%llx is already locked, do not write it.",
mft_no);
return false;
}
ntfs_debug("Managed to lock extent mft record 0x%lx, write it.",
ntfs_debug("Managed to lock extent mft record 0x%llx, write it.",
mft_no);
/*
* The write has to occur while we hold the mft record lock so return
@ -941,7 +938,7 @@ static const char *es = " Leaving inconsistent metadata. Unmount and run chkds
*
* Locking: Caller must hold vol->mftbmp_lock for writing.
*/
static int ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(struct ntfs_volume *vol,
static s64 ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(struct ntfs_volume *vol,
struct ntfs_inode *base_ni)
{
s64 pass_end, ll, data_pos, pass_start, ofs, bit;
@ -2711,7 +2708,7 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
sizeof(struct inode *), GFP_NOFS);
int nr_ref_inos = 0;
struct bio *bio = NULL;
unsigned long mft_no;
u64 mft_no;
struct ntfs_inode *tni;
s64 lcn;
s64 vcn = ntfs_pidx_to_cluster(vol, folio->index);
@ -2875,7 +2872,7 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
else
base_tni = tni->ext.base_ntfs_ino;
mutex_unlock(&tni->extent_lock);
ntfs_debug("Unlocking %s inode 0x%lx.",
ntfs_debug("Unlocking %s inode 0x%llx.",
tni == base_tni ? "base" : "extent",
tni->mft_no);
atomic_dec(&tni->count);

View File

@ -42,7 +42,7 @@ static inline void mark_mft_record_dirty(struct ntfs_inode *ni)
__mark_mft_record_dirty(ni);
}
int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const unsigned long mft_no,
int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const u64 mft_no,
struct mft_record *m);
int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int sync);
@ -76,9 +76,6 @@ static inline int write_mft_record(struct ntfs_inode *ni, struct mft_record *m,
return err;
}
bool ntfs_may_write_mft_record(struct ntfs_volume *vol,
const unsigned long mft_no, const struct mft_record *m,
struct ntfs_inode **locked_ni, struct inode **ref_vi);
int ntfs_mft_record_alloc(struct ntfs_volume *vol, const int mode,
struct ntfs_inode **ni, struct ntfs_inode *base_ni,
struct mft_record **ni_mrec);
@ -86,7 +83,7 @@ int ntfs_mft_record_free(struct ntfs_volume *vol, struct ntfs_inode *ni);
int ntfs_mft_records_write(const struct ntfs_volume *vol, const u64 mref,
const s64 count, struct mft_record *b);
int ntfs_mft_record_check(const struct ntfs_volume *vol, struct mft_record *m,
unsigned long mft_no);
u64 mft_no);
int ntfs_mft_writepages(struct address_space *mapping,
struct writeback_control *wbc);
void ntfs_mft_mark_dirty(struct folio *folio);

View File

@ -508,7 +508,7 @@ static struct ntfs_inode *__ntfs_create(struct mnt_idmap *idmap, struct inode *d
spin_unlock(&vi->i_lock);
/* Add the inode to the inode hash for the superblock. */
vi->i_ino = ni->mft_no;
vi->i_ino = (unsigned long)ni->mft_no;
inode_set_iversion(vi, 1);
insert_inode_hash(vi);
@ -521,7 +521,7 @@ static struct ntfs_inode *__ntfs_create(struct mnt_idmap *idmap, struct inode *d
dni_mrec = map_mft_record(dir_ni);
if (IS_ERR(dni_mrec)) {
ntfs_error(dir_ni->vol->sb, "failed to map mft record for file %ld.\n",
ntfs_error(dir_ni->vol->sb, "failed to map mft record for file 0x%llx.\n",
dir_ni->mft_no);
err = -EIO;
goto err_out;
@ -810,7 +810,7 @@ static int ntfs_check_unlinkable_dir(struct ntfs_attr_search_ctx *ctx, struct fi
static int ntfs_test_inode_attr(struct inode *vi, void *data)
{
struct ntfs_inode *ni = NTFS_I(vi);
unsigned long mft_no = (unsigned long)data;
u64 mft_no = (u64)data;
if (ni->mft_no != mft_no)
return 0;
@ -904,7 +904,7 @@ static int ntfs_delete(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
/* Ignore hard links from other directories */
if (dir_ni->mft_no != MREF_LE(fn->parent_directory)) {
ntfs_debug("MFT record numbers don't match (%lu != %lu)\n",
ntfs_debug("MFT record numbers don't match (%llu != %lu)\n",
dir_ni->mft_no,
MREF_LE(fn->parent_directory));
continue;
@ -1363,7 +1363,7 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (err) {
int err2;
ntfs_error(sb, "Failed to delete old ntfs inode(%ld) in old dir, err : %d\n",
ntfs_error(sb, "Failed to delete old ntfs inode(%llu) in old dir, err : %d\n",
old_ni->mft_no, err);
err2 = ntfs_delete(old_ni, new_dir_ni, uname_new, new_name_len, false);
if (err2)