From: Joe Perches <joe@perches.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
ntfs3@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/6] fs/ntfs3: Refactoring attr_punch_hole to restore after errors
Date: Wed, 13 Jul 2022 11:58:48 -0700 [thread overview]
Message-ID: <4d7e96ac0125bf8296689385f3f9dd54f7e2c0f1.camel@perches.com> (raw)
In-Reply-To: <33c5b044-23a4-60a6-1649-9e5db228c2f7@paragon-software.com>
On Wed, 2022-07-13 at 19:46 +0300, Konstantin Komarov wrote:
> Added comments to code
> Added new function run_clone to make a copy of run
> Added done and undo labels for restoring after errors
trivia:
> diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
[]
> index 7bcae3094712..24d545041787 100644llocate_ex(struct ntfs_sb_info *sbi, struct runs_tree *run,
> }
>
> if (lcn != SPARSE_LCN) {
> - mark_as_free_ex(sbi, lcn, clen, trim);
> + if (sbi) {
> + /* mark bitmap range [lcn + clen) as free and trim clusters. */
presumably the brackets or parentheses [ ) should match
[]
> @@ -2091,69 +2098,91 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size)
[]
> +
> + /* Make a hole range (sparse) [vcn1 + zero). */
here too
> diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
[]
> @@ -1157,3 +1157,28 @@ int run_get_highest_vcn(CLST vcn, const u8 *run_buf, u64 *highest_vcn)
> *highest_vcn = vcn64 - 1;
> return 0;
> }
> +
> +/*
> + * run_clone
> + *
> + * Make a copy of run
> + */
> +int run_clone(const struct runs_tree *run, struct runs_tree *new_run)
> +{
> + size_t bytes = run->count * sizeof(struct ntfs_run);
> +
> + if (bytes > new_run->allocated) {
> + struct ntfs_run *new_ptr = kvmalloc(bytes, GFP_KERNEL);
kvmalloc_array ?
> +
> + if (!new_ptr)
> + return -ENOMEM;
> +
> + kvfree(new_run->runs);
> + new_run->runs = new_ptr;
> + new_run->allocated = bytes;
> + }
> +
> + memcpy(new_run->runs, run->runs, bytes);
> + new_run->count = run->count;
> + return 0;
> +}
next prev parent reply other threads:[~2022-07-13 18:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 16:44 [PATCH 0/6] fs/ntfs3: Refactoring of several functions Konstantin Komarov
2022-07-13 16:45 ` [PATCH 1/6] fs/ntfs3: New function ntfs_bad_inode Konstantin Komarov
2022-07-13 16:45 ` [PATCH 2/6] fs/ntfs3: Refactoring attr_set_size to restore after errors Konstantin Komarov
2022-07-13 16:46 ` [PATCH 3/6] fs/ntfs3: Refactoring attr_punch_hole " Konstantin Komarov
2022-07-13 18:58 ` Joe Perches [this message]
2022-07-13 16:46 ` [PATCH 4/6] fs/ntfs3: Refactoring attr_insert_range " Konstantin Komarov
2022-07-13 16:47 ` [PATCH 5/6] fs/ntfs3: Create MFT zone only if length is large enough Konstantin Komarov
2022-07-13 16:47 ` [PATCH 6/6] fs/ntfs3: Make ni_ins_new_attr return error Konstantin Komarov
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=4d7e96ac0125bf8296689385f3f9dd54f7e2c0f1.camel@perches.com \
--to=joe@perches.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
/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®