]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs/ntfs3: format code, deal with comments
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Wed, 27 May 2026 08:23:28 +0000 (10:23 +0200)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 2 Jun 2026 15:02:36 +0000 (17:02 +0200)
format code according to .clang-format, add useful comments and remove
non-useful comments.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/attrib.c
fs/ntfs3/frecord.c
fs/ntfs3/fsntfs.c
fs/ntfs3/index.c
fs/ntfs3/inode.c

index 0caf2f8a8c1e83c3cc9826e09b9e1c3238c84296..a85d3ee51091670c0b4df007b586a5293d83f0e0 100644 (file)
@@ -1152,7 +1152,7 @@ again:
                        struct ATTRIB *attr2;
 
                        attr2 = ni_find_attr(ni, attr_b, &le_b, ATTR_DATA, NULL,
-                                              0, &vcn0, &mi);
+                                            0, &vcn0, &mi);
                        if (!attr2) {
                                err = -EINVAL;
                                goto out;
index 4b5dd3de327ba99a0ae1d93f8670935cfac0e4f9..0d98bc932c24d57f574cf02df69a332d088ceaf8 100644 (file)
@@ -1855,8 +1855,8 @@ enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr,
 static struct folio *ntfs_lock_new_page(struct address_space *mapping,
                                        pgoff_t index, gfp_t gfp)
 {
-       struct folio *folio = __filemap_get_folio(mapping, index,
-                       FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp);
+       struct folio *folio = __filemap_get_folio(
+               mapping, index, FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp);
 
        if (IS_ERR(folio))
                return folio;
index d0434756029b61ed5f5e571b5b21da6dad29f6c1..bc7469d0a34d40988a1fd910f65ae935235b3452 100644 (file)
@@ -2654,7 +2654,6 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len)
        struct ATTRIB *attr;
        u32 uni_bytes;
        struct ntfs_inode *ni = sbi->volume.ni;
-       /* Allocate PATH_MAX bytes. */
        struct cpu_str *uni = kmalloc(PATH_MAX, GFP_KERNEL);
 
        if (!uni)
index 85f674e9e361cd8526078b4423016e6d0c62544a..7d6bb14893e9dd1b495ae377c66bc97176e4958d 100644 (file)
@@ -1623,7 +1623,8 @@ out1:
 static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
                                 const struct NTFS_DE *new_de,
                                 struct NTFS_DE *root_de, const void *ctx,
-                                struct ntfs_fnd *fnd, bool undo, NTFS_CMP_FUNC cmp)
+                                struct ntfs_fnd *fnd, bool undo,
+                                NTFS_CMP_FUNC cmp)
 {
        int err = 0;
        struct NTFS_DE *e, *e0, *re;
@@ -1848,13 +1849,15 @@ out_free_root:
  * Attempt to insert an entry into an Index Allocation Buffer.
  * If necessary, it will split the buffer.
  */
-static int
-indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
-                       struct INDEX_ROOT *root, const struct NTFS_DE *new_de,
-                       const void *ctx, int level, struct ntfs_fnd *fnd, NTFS_CMP_FUNC cmp)
+static int indx_insert_into_buffer(struct ntfs_index *indx,
+                                  struct ntfs_inode *ni,
+                                  struct INDEX_ROOT *root,
+                                  const struct NTFS_DE *new_de,
+                                  const void *ctx, int level,
+                                  struct ntfs_fnd *fnd, NTFS_CMP_FUNC cmp)
 {
        int err;
-       const struct NTFS_DE *sp;
+       const struct NTFS_DE *sp; /* split_point */
        struct NTFS_DE *e, *de_t, *up_e;
        struct indx_node *n2;
        struct indx_node *n1 = fnd->nodes[level];
@@ -1880,10 +1883,9 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
         * No space to insert into buffer. Split it.
         * To split we:
         *  - Save split point ('cause index buffers will be changed)
-        * - Allocate NewBuffer and copy all entries <= sp into new buffer
-        * - Remove all entries (sp including) from TargetBuffer
-        * - Insert NewEntry into left or right buffer (depending on sp <=>
-        *     NewEntry)
+        * - Allocate new buffer (up_e) and copy all entries <= sp into new buffer
+        * - Remove all entries (sp including) from hdr1
+        * - Insert new_de into left or right buffer (depending on sp <=> new_de)
         * - Insert sp into parent buffer (or root)
         * - Make sp a parent for new buffer
         */
@@ -1897,6 +1899,7 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
                return -ENOMEM;
        memcpy(up_e, sp, sp_size);
 
+       /* Make a copy for undo. */
        used1 = le32_to_cpu(hdr1->used);
 
        /*
@@ -1960,8 +1963,7 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
         */
        hdr_insert_de(indx,
                      (*cmp)(new_de + 1, le16_to_cpu(new_de->key_size),
-                                  up_e + 1, le16_to_cpu(up_e->key_size),
-                                  ctx) < 0 ?
+                            up_e + 1, le16_to_cpu(up_e->key_size), ctx) < 0 ?
                              hdr2 :
                              hdr1,
                      new_de, NULL, ctx, cmp);
@@ -1978,11 +1980,13 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
         * insert the promoted entry into the parent.
         */
        if (!level) {
-               /* Insert in root. */
-               err = indx_insert_into_root(indx, ni, up_e, NULL, ctx, fnd, 0, cmp);
+               /* Insert split_point in root. */
+               err = indx_insert_into_root(indx, ni, up_e, NULL, ctx, fnd, 0,
+                                           cmp);
        } else {
                /*
                 * The target buffer's parent is another index buffer.
+                * Insert split_point in parent index ( call itself recursively )
                 * TODO: Remove recursion.
                 */
                err = indx_insert_into_buffer(indx, ni, root, up_e, ctx,
index 2d3aad60caa4650baebc450edb58d59eab735228..7423e8c897384132dd241592fb7a3247d8df3899 100644 (file)
@@ -592,7 +592,6 @@ static void ntfs_iomap_read_end_io(struct bio *bio)
                u32 f_size = folio_size(folio);
                loff_t f_pos = folio_pos(folio);
 
-
                if (valid < f_pos + f_size) {
                        u32 z_from = valid <= f_pos ?
                                             0 :
@@ -765,7 +764,7 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
                clen_max = bytes_to_cluster(sbi, endbyte) - vcn;
        }
 
-       /* 
+       /*
         * Force to allocate clusters if directIO(write) or writeback_range.
         * NOTE: attr_data_get_block allocates clusters only for sparse file.
         * Normal file allocates clusters in attr_set_size.
@@ -830,7 +829,6 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
                iomap->type = IOMAP_DELALLOC;
                iomap->addr = IOMAP_NULL_ADDR;
        } else {
-
                /* Translate clusters into bytes. */
                iomap->addr = ((loff_t)lcn << cluster_bits) + off;
                if (length && iomap->length > length)
@@ -987,7 +985,6 @@ static ssize_t ntfs_writeback_range(struct iomap_writepage_ctx *wpc,
        return iomap_add_to_ioend(wpc, folio, offset, end_pos, len);
 }
 
-
 static const struct iomap_writeback_ops ntfs_writeback_ops = {
        .writeback_range = ntfs_writeback_range,
        .writeback_submit = iomap_ioend_writeback_submit,
@@ -1000,7 +997,7 @@ static int ntfs_writepages(struct address_space *mapping,
        struct inode *inode = mapping->host;
        struct ntfs_inode *ni = ntfs_i(inode);
        struct iomap_writepage_ctx wpc = {
-               .inode = mapping->host,
+               .inode = inode,
                .wbc = wbc,
                .ops = &ntfs_writeback_ops,
        };
@@ -1280,7 +1277,6 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
        if (!(mode & 0222))
                fa |= FILE_ATTRIBUTE_READONLY;
 
-       /* Allocate PATH_MAX bytes. */
        new_de = kzalloc(PATH_MAX, GFP_KERNEL);
        if (!new_de) {
                err = -ENOMEM;
@@ -1719,7 +1715,6 @@ int ntfs_link_inode(struct inode *inode, struct dentry *dentry)
        struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info;
        struct NTFS_DE *de;
 
-       /* Allocate PATH_MAX bytes. */
        de = kzalloc(PATH_MAX, GFP_KERNEL);
        if (!de)
                return -ENOMEM;