Skip to content

Commit 723325d

Browse files
fs/ntfs3: format code, deal with comments
format code according to .clang-format, add useful comments and remove non-useful comments. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent a82fbf4 commit 723325d

5 files changed

Lines changed: 23 additions & 25 deletions

File tree

fs/ntfs3/attrib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ int attr_data_get_block_locked(struct ntfs_inode *ni, CLST vcn, CLST clen,
11521152
struct ATTRIB *attr2;
11531153

11541154
attr2 = ni_find_attr(ni, attr_b, &le_b, ATTR_DATA, NULL,
1155-
0, &vcn0, &mi);
1155+
0, &vcn0, &mi);
11561156
if (!attr2) {
11571157
err = -EINVAL;
11581158
goto out;

fs/ntfs3/frecord.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,8 +1855,8 @@ enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr,
18551855
static struct folio *ntfs_lock_new_page(struct address_space *mapping,
18561856
pgoff_t index, gfp_t gfp)
18571857
{
1858-
struct folio *folio = __filemap_get_folio(mapping, index,
1859-
FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp);
1858+
struct folio *folio = __filemap_get_folio(
1859+
mapping, index, FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp);
18601860

18611861
if (IS_ERR(folio))
18621862
return folio;

fs/ntfs3/fsntfs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,6 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len)
26542654
struct ATTRIB *attr;
26552655
u32 uni_bytes;
26562656
struct ntfs_inode *ni = sbi->volume.ni;
2657-
/* Allocate PATH_MAX bytes. */
26582657
struct cpu_str *uni = kmalloc(PATH_MAX, GFP_KERNEL);
26592658

26602659
if (!uni)

fs/ntfs3/index.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,8 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
16231623
static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
16241624
const struct NTFS_DE *new_de,
16251625
struct NTFS_DE *root_de, const void *ctx,
1626-
struct ntfs_fnd *fnd, bool undo, NTFS_CMP_FUNC cmp)
1626+
struct ntfs_fnd *fnd, bool undo,
1627+
NTFS_CMP_FUNC cmp)
16271628
{
16281629
int err = 0;
16291630
struct NTFS_DE *e, *e0, *re;
@@ -1848,13 +1849,15 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
18481849
* Attempt to insert an entry into an Index Allocation Buffer.
18491850
* If necessary, it will split the buffer.
18501851
*/
1851-
static int
1852-
indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
1853-
struct INDEX_ROOT *root, const struct NTFS_DE *new_de,
1854-
const void *ctx, int level, struct ntfs_fnd *fnd, NTFS_CMP_FUNC cmp)
1852+
static int indx_insert_into_buffer(struct ntfs_index *indx,
1853+
struct ntfs_inode *ni,
1854+
struct INDEX_ROOT *root,
1855+
const struct NTFS_DE *new_de,
1856+
const void *ctx, int level,
1857+
struct ntfs_fnd *fnd, NTFS_CMP_FUNC cmp)
18551858
{
18561859
int err;
1857-
const struct NTFS_DE *sp;
1860+
const struct NTFS_DE *sp; /* split_point */
18581861
struct NTFS_DE *e, *de_t, *up_e;
18591862
struct indx_node *n2;
18601863
struct indx_node *n1 = fnd->nodes[level];
@@ -1880,10 +1883,9 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
18801883
* No space to insert into buffer. Split it.
18811884
* To split we:
18821885
* - Save split point ('cause index buffers will be changed)
1883-
* - Allocate NewBuffer and copy all entries <= sp into new buffer
1884-
* - Remove all entries (sp including) from TargetBuffer
1885-
* - Insert NewEntry into left or right buffer (depending on sp <=>
1886-
* NewEntry)
1886+
* - Allocate new buffer (up_e) and copy all entries <= sp into new buffer
1887+
* - Remove all entries (sp including) from hdr1
1888+
* - Insert new_de into left or right buffer (depending on sp <=> new_de)
18871889
* - Insert sp into parent buffer (or root)
18881890
* - Make sp a parent for new buffer
18891891
*/
@@ -1897,6 +1899,7 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
18971899
return -ENOMEM;
18981900
memcpy(up_e, sp, sp_size);
18991901

1902+
/* Make a copy for undo. */
19001903
used1 = le32_to_cpu(hdr1->used);
19011904

19021905
/*
@@ -1960,8 +1963,7 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
19601963
*/
19611964
hdr_insert_de(indx,
19621965
(*cmp)(new_de + 1, le16_to_cpu(new_de->key_size),
1963-
up_e + 1, le16_to_cpu(up_e->key_size),
1964-
ctx) < 0 ?
1966+
up_e + 1, le16_to_cpu(up_e->key_size), ctx) < 0 ?
19651967
hdr2 :
19661968
hdr1,
19671969
new_de, NULL, ctx, cmp);
@@ -1978,11 +1980,13 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
19781980
* insert the promoted entry into the parent.
19791981
*/
19801982
if (!level) {
1981-
/* Insert in root. */
1982-
err = indx_insert_into_root(indx, ni, up_e, NULL, ctx, fnd, 0, cmp);
1983+
/* Insert split_point in root. */
1984+
err = indx_insert_into_root(indx, ni, up_e, NULL, ctx, fnd, 0,
1985+
cmp);
19831986
} else {
19841987
/*
19851988
* The target buffer's parent is another index buffer.
1989+
* Insert split_point in parent index ( call itself recursively )
19861990
* TODO: Remove recursion.
19871991
*/
19881992
err = indx_insert_into_buffer(indx, ni, root, up_e, ctx,

fs/ntfs3/inode.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ static void ntfs_iomap_read_end_io(struct bio *bio)
592592
u32 f_size = folio_size(folio);
593593
loff_t f_pos = folio_pos(folio);
594594

595-
596595
if (valid < f_pos + f_size) {
597596
u32 z_from = valid <= f_pos ?
598597
0 :
@@ -765,7 +764,7 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
765764
clen_max = bytes_to_cluster(sbi, endbyte) - vcn;
766765
}
767766

768-
/*
767+
/*
769768
* Force to allocate clusters if directIO(write) or writeback_range.
770769
* NOTE: attr_data_get_block allocates clusters only for sparse file.
771770
* 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,
830829
iomap->type = IOMAP_DELALLOC;
831830
iomap->addr = IOMAP_NULL_ADDR;
832831
} else {
833-
834832
/* Translate clusters into bytes. */
835833
iomap->addr = ((loff_t)lcn << cluster_bits) + off;
836834
if (length && iomap->length > length)
@@ -987,7 +985,6 @@ static ssize_t ntfs_writeback_range(struct iomap_writepage_ctx *wpc,
987985
return iomap_add_to_ioend(wpc, folio, offset, end_pos, len);
988986
}
989987

990-
991988
static const struct iomap_writeback_ops ntfs_writeback_ops = {
992989
.writeback_range = ntfs_writeback_range,
993990
.writeback_submit = iomap_ioend_writeback_submit,
@@ -1000,7 +997,7 @@ static int ntfs_writepages(struct address_space *mapping,
1000997
struct inode *inode = mapping->host;
1001998
struct ntfs_inode *ni = ntfs_i(inode);
1002999
struct iomap_writepage_ctx wpc = {
1003-
.inode = mapping->host,
1000+
.inode = inode,
10041001
.wbc = wbc,
10051002
.ops = &ntfs_writeback_ops,
10061003
};
@@ -1280,7 +1277,6 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
12801277
if (!(mode & 0222))
12811278
fa |= FILE_ATTRIBUTE_READONLY;
12821279

1283-
/* Allocate PATH_MAX bytes. */
12841280
new_de = kzalloc(PATH_MAX, GFP_KERNEL);
12851281
if (!new_de) {
12861282
err = -ENOMEM;
@@ -1719,7 +1715,6 @@ int ntfs_link_inode(struct inode *inode, struct dentry *dentry)
17191715
struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info;
17201716
struct NTFS_DE *de;
17211717

1722-
/* Allocate PATH_MAX bytes. */
17231718
de = kzalloc(PATH_MAX, GFP_KERNEL);
17241719
if (!de)
17251720
return -ENOMEM;

0 commit comments

Comments
 (0)