Skip to contentSkip to conversation

fs/ntfs3: Deadcoding

PATCH New [email protected] 1 participant 4 messages Feb 19, 2025 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

cover fs/ntfs3: Deadcoding

From: "Dr. David Alan Gilbert" <[email protected]>

Hi,
This is a small set of deadcode removal;
whole functions that haven't been called.

Note the last one in the set has a commented
out call which makes me a little suspicious what the intent is.

Dave

Dr. David Alan Gilbert (3):
fs/ntfs3: Remove unused ni_load_attr
fs/ntfs3: Remove unused ntfs_sb_read
fs/ntfs3: Remove unused ntfs_flush_inodes

 fs/ntfs3/frecord.c | 57 ----------------------------------------------
 fs/ntfs3/fsntfs.c  | 28 -----------------------
 fs/ntfs3/inode.c   | 40 --------------------------------
 fs/ntfs3/ntfs_fs.h |  6 -----
 4 files changed, 131 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/3 fs/ntfs3: Remove unused ni_load_attr

From: "Dr. David Alan Gilbert" <[email protected]>

ni_load_attr() was added in 2021 by
commit 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") but hasn't been used.

Remove it.

---
 fs/ntfs3/frecord.c | 57 ----------------------------------------------
 fs/ntfs3/ntfs_fs.h |  3 ---
 2 files changed, 60 deletions(-)
fs/ntfs3/frecord.c +0 -57
index 5df6a0b5add9..d227f9923290 100644
@@ -280,63 +280,6 @@ struct ATTRIB *ni_enum_attr_ex(struct ntfs_inode *ni, struct ATTRIB *attr,
 	return rec_find_attr_le(ni, mi2, le2);
 }
 
-/*
- * ni_load_attr - Load attribute that contains given VCN.
- */
-struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
-			    const __le16 *name, u8 name_len, CLST vcn,
-			    struct mft_inode **pmi)
-{
-	struct ATTR_LIST_ENTRY *le;
-	struct ATTRIB *attr;
-	struct mft_inode *mi;
-	struct ATTR_LIST_ENTRY *next;
-
-	if (!ni->attr_list.size) {
-		if (pmi)
-			*pmi = &ni->mi;
-		return mi_find_attr(ni, &ni->mi, NULL, type, name, name_len,
-				    NULL);
-	}
-
-	le = al_find_ex(ni, NULL, type, name, name_len, NULL);
-	if (!le)
-		return NULL;
-
-	/*
-	 * Unfortunately ATTR_LIST_ENTRY contains only start VCN.
-	 * So to find the ATTRIB segment that contains 'vcn' we should
-	 * enumerate some entries.
-	 */
-	if (vcn) {
-		for (;; le = next) {
-			next = al_find_ex(ni, le, type, name, name_len, NULL);
-			if (!next || le64_to_cpu(next->vcn) > vcn)
-				break;
-		}
-	}
-
-	if (ni_load_mi(ni, le, &mi))
-		return NULL;
-
-	if (pmi)
-		*pmi = mi;
-
-	attr = mi_find_attr(ni, mi, NULL, type, name, name_len, &le->id);
-	if (!attr)
-		return NULL;
-
-	if (!attr->non_res)
-		return attr;
-
-	if (le64_to_cpu(attr->nres.svcn) <= vcn &&
-	    vcn <= le64_to_cpu(attr->nres.evcn))
-		return attr;
-
-	_ntfs_bad_inode(&ni->vfs_inode);
-	return NULL;
-}
-
 /*
  * ni_load_all_mi - Load all subrecords.
  */
fs/ntfs3/ntfs_fs.h +0 -3
index 382820464dee..2034dca90a5e 100644
@@ -530,9 +530,6 @@ struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr,
 struct ATTRIB *ni_enum_attr_ex(struct ntfs_inode *ni, struct ATTRIB *attr,
 			       struct ATTR_LIST_ENTRY **le,
 			       struct mft_inode **mi);
-struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
-			    const __le16 *name, u8 name_len, CLST vcn,
-			    struct mft_inode **pmi);
 int ni_load_all_mi(struct ntfs_inode *ni);
 bool ni_add_subrecord(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi);
 int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
Signature · 1 line
2.48.1
#2 lore raw

PATCH 2/3 fs/ntfs3: Remove unused ntfs_sb_read

In reply to [email protected]

From: "Dr. David Alan Gilbert" <[email protected]>

ntfs_sb_read() was added in 2021 by
commit 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") but hasn't been used.

Remove it.

---
 fs/ntfs3/fsntfs.c  | 28 ----------------------------
 fs/ntfs3/ntfs_fs.h |  1 -
 2 files changed, 29 deletions(-)
fs/ntfs3/fsntfs.c +0 -28
index 938d351ebac7..df81f1f7330c 100644
@@ -1035,34 +1035,6 @@ struct buffer_head *ntfs_bread(struct super_block *sb, sector_t block)
 	return NULL;
 }
 
-int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer)
-{
-	struct block_device *bdev = sb->s_bdev;
-	u32 blocksize = sb->s_blocksize;
-	u64 block = lbo >> sb->s_blocksize_bits;
-	u32 off = lbo & (blocksize - 1);
-	u32 op = blocksize - off;
-
-	for (; bytes; block += 1, off = 0, op = blocksize) {
-		struct buffer_head *bh = __bread(bdev, block, blocksize);
-
-		if (!bh)
-			return -EIO;
-
-		if (op > bytes)
-			op = bytes;
-
-		memcpy(buffer, bh->b_data + off, op);
-
-		put_bh(bh);
-
-		bytes -= op;
-		buffer = Add2Ptr(buffer, op);
-	}
-
-	return 0;
-}
-
 int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 		  const void *buf, int wait)
 {
fs/ntfs3/ntfs_fs.h +0 -1
index 2034dca90a5e..0e34c944b622 100644
@@ -616,7 +616,6 @@ enum NTFS_DIRTY_FLAGS {
 	NTFS_DIRTY_ERROR = 2,
 };
 int ntfs_set_state(struct ntfs_sb_info *sbi, enum NTFS_DIRTY_FLAGS dirty);
-int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer);
 int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 		  const void *buffer, int wait);
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
Signature · 1 line
2.48.1
#3 lore raw

PATCH 3/3 fs/ntfs3: Remove unused ntfs_flush_inodes

In reply to [email protected]

From: "Dr. David Alan Gilbert" <[email protected]>

ntfs_flush_inodes() was added in 2021 by
commit 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") but has remained unused.

Remove it, and it's helper function.

Note: There is a commented out call to ntfs_flush_inodes in ntfs_truncate() - I've left that in place.

---
 fs/ntfs3/inode.c   | 40 ----------------------------------------
 fs/ntfs3/ntfs_fs.h |  2 --
 2 files changed, 42 deletions(-)
fs/ntfs3/inode.c +0 -40
index a1e11228dafd..3e2957a1e360 100644
@@ -1024,46 +1024,6 @@ int ntfs_sync_inode(struct inode *inode)
 	return _ni_write_inode(inode, 1);
 }
 
-/*
- * writeback_inode - Helper function for ntfs_flush_inodes().
- *
- * This writes both the inode and the file data blocks, waiting
- * for in flight data blocks before the start of the call.  It
- * does not wait for any io started during the call.
- */
-static int writeback_inode(struct inode *inode)
-{
-	int ret = sync_inode_metadata(inode, 0);
-
-	if (!ret)
-		ret = filemap_fdatawrite(inode->i_mapping);
-	return ret;
-}
-
-/*
- * ntfs_flush_inodes
- *
- * Write data and metadata corresponding to i1 and i2.  The io is
- * started but we do not wait for any of it to finish.
- *
- * filemap_flush() is used for the block device, so if there is a dirty
- * page for a block already in flight, we will not wait and start the
- * io over again.
- */
-int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,
-		      struct inode *i2)
-{
-	int ret = 0;
-
-	if (i1)
-		ret = writeback_inode(i1);
-	if (!ret && i2)
-		ret = writeback_inode(i2);
-	if (!ret)
-		ret = filemap_flush(sb->s_bdev_file->f_mapping);
-	return ret;
-}
-
 /*
  * Helper function to read file.
  */
fs/ntfs3/ntfs_fs.h +0 -2
index 0e34c944b622..d628977e2556 100644
@@ -713,8 +713,6 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 		   u32 len, u32 copied, struct folio *folio, void *fsdata);
 int ntfs3_write_inode(struct inode *inode, struct writeback_control *wbc);
 int ntfs_sync_inode(struct inode *inode);
-int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,
-		      struct inode *i2);
 int inode_read_data(struct inode *inode, void *data, size_t bytes);
 int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
 		      struct dentry *dentry, const struct cpu_str *uni,
Signature · 1 line
2.48.1