linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	linux-fsdevel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org,
	pali@kernel.org, dsterba@suse.cz, aaptel@suse.com,
	willy@infradead.org, rdunlap@infradead.org, joe@perches.com,
	mark@harmstone.com, nborisov@suse.com,
	linux-ntfs-dev@lists.sourceforge.net, anton@tuxera.com,
	dan.carpenter@oracle.com, hch@lst.de, ebiggers@kernel.org,
	andy.lavr@gmail.com, kari.argillander@gmail.com,
	oleksandr@natalenko.name
Subject: Re: [PATCH v27 07/10] fs/ntfs3: Add NTFS journal
Date: Fri, 30 Jul 2021 10:06:17 +0200	[thread overview]
Message-ID: <526c746b-2615-6a27-f753-4655571a5462@wanadoo.fr> (raw)
In-Reply-To: <20210729134943.778917-8-almaz.alexandrovich@paragon-software.com>

Hi,

below are a few comments based on a cppcheck run.
Don't take it too seriously into consideration. It could be either some 
useless code that could be removed or some issues in the logic.

It is reported only if a new iteration is done and if it makes sense to 
change something.

CJ

Le 29/07/2021 à 15:49, Konstantin Komarov a écrit :
> This adds NTFS journal
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>   fs/ntfs3/fslog.c | 5181 ++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 5181 insertions(+)
>   create mode 100644 fs/ntfs3/fslog.c
> 
> diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
> new file mode 100644
> index 000000000..53da12252
> --- /dev/null
> +++ b/fs/ntfs3/fslog.c

[...]

> +/*
> + * last_log_lsn
> + *
> + * This routine walks through the log pages for a file, searching for the
> + * last log page written to the file
> + */
> +static int last_log_lsn(struct ntfs_log *log)
> +{

[...]

> +tail_read:
> +	first_tail = first_tail_prev;
> +	final_off = final_off_prev;
> +
> +	second_tail = second_tail_prev;
> +	second_off = second_off_prev;
> +
> +	page_cnt = page_pos = 1;
> +
> +	curpage_off = seq_base == log->seq_num ? min(log->next_page, page_off)
> +					       : log->next_page;
> +
> +	wrapped_file =
> +		curpage_off == log->first_page &&
> +		!(log->l_flags & (NTFSLOG_NO_LAST_LSN | NTFSLOG_REUSE_TAIL));
> +
> +	expected_seq = wrapped_file ? (log->seq_num + 1) : log->seq_num;
> +
> +	nextpage_off = curpage_off;

This 'nextpage_off' is overwritten a few lines below.
Either it is useless, either there is an issue in the logic.

> +
> +next_page:
> +	tail_page = NULL;
> +	/* Read the next log page */
> +	err = read_log_page(log, curpage_off, &page, &usa_error);
> +
> +	/* Compute the next log page offset the file */
> +	nextpage_off = next_page_off(log, curpage_off);
> +	wrapped = nextpage_off == log->first_page;
here.

> +
> +	if (tails > 1) {
> +		struct RECORD_PAGE_HDR *cur_page =
> +			Add2Ptr(page_bufs, curpage_off - page_off);
> +
> +		if (curpage_off == saved_off) {
> +			tail_page = cur_page;
> +			goto use_tail_page;
> +		}
> +

[...]

> +int log_replay(struct ntfs_inode *ni, bool *initialized)
> +{

[...]

> +
> +	vcn = le64_to_cpu(lrh->target_vcn);
> +	vcn &= ~(log->clst_per_page - 1);
> +

This 'vcn' is overwritten a few lines below.
Either it is useless, either there is an issue in the logic.

> +add_allocated_vcns:
> +	for (i = 0, vcn = le64_to_cpu(lrh->target_vcn),

here

> +	    size = (vcn + 1) << sbi->cluster_bits;
> +	     i < t16; i++, vcn += 1, size += sbi->cluster_size) {
> +		attr = oa->attr;
> +		if (!attr->non_res) {
> +			if (size > le32_to_cpu(attr->res.data_size))
> +				attr->res.data_size = cpu_to_le32(size);
> +		} else {
> +			if (size > le64_to_cpu(attr->nres.data_size))
> +				attr->nres.valid_size = attr->nres.data_size =
> +					attr->nres.alloc_size =
> +						cpu_to_le64(size);
> +		}
> +	}
> +
> +	t16 = le16_to_cpu(lrh->undo_op);
> +	if (can_skip_action(t16))
> +		goto read_next_log_undo_action;
> +
> +	/* Point to the Redo data and get its length */
> +	data = Add2Ptr(lrh, le16_to_cpu(lrh->undo_off));
> +	dlen = le16_to_cpu(lrh->undo_len);
> +
> +	/* it is time to apply the undo action */
> +	err = do_action(log, oe, lrh, t16, data, dlen, rec_len, NULL);

This 'err' is unused.
Maybe there is nothing that we can do, or the error handling is missing.

> +
> +read_next_log_undo_action:
> +	/*
> +	 * Keep reading and looping back until we have read the
> +	 * last record for this transaction
> +	 */
> +	err = read_next_log_rec(log, lcb, &rec_lsn);
> +	if (err)
> +		goto out;
> +

[...]

  reply	other threads:[~2021-07-30  8:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 13:49 [PATCH v27 00/10] NTFS read-write driver GPL implementation by Paragon Software Konstantin Komarov
2021-07-29 13:49 ` [PATCH v27 01/10] fs/ntfs3: Add headers and misc files Konstantin Komarov
2021-07-29 13:49 ` [PATCH v27 02/10] fs/ntfs3: Add initialization of super block Konstantin Komarov
2021-07-29 15:59   ` Matthew Wilcox
2021-07-30  8:28   ` Christophe JAILLET
2021-08-10  9:02   ` Christoph Hellwig
2021-07-29 13:49 ` [PATCH v27 03/10] fs/ntfs3: Add bitmap Konstantin Komarov
2021-07-30  8:11   ` Christophe JAILLET
2021-07-29 13:49 ` [PATCH v27 04/10] fs/ntfs3: Add file operations and implementation Konstantin Komarov
2021-07-30  7:40   ` Christophe JAILLET
2021-08-22 12:20   ` Pali Rohár
2021-08-22 14:31     ` Kari Argillander
2021-08-24 11:33       ` Pali Rohár
2021-07-29 13:49 ` [PATCH v27 05/10] fs/ntfs3: Add attrib operations Konstantin Komarov
2021-07-30  7:30   ` Christophe JAILLET
2021-07-29 13:49 ` [PATCH v27 06/10] fs/ntfs3: Add compression Konstantin Komarov
2021-07-29 13:49 ` [PATCH v27 07/10] fs/ntfs3: Add NTFS journal Konstantin Komarov
2021-07-30  8:06   ` Christophe JAILLET [this message]
2021-07-29 13:49 ` [PATCH v27 08/10] fs/ntfs3: Add Kconfig, Makefile and doc Konstantin Komarov
2021-08-10  7:47   ` Kari Argillander
2021-08-10  8:19     ` Pali Rohár
2021-08-10  8:46       ` Kari Argillander
2021-07-29 13:49 ` [PATCH v27 09/10] fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile Konstantin Komarov
2021-07-29 13:49 ` [PATCH v27 10/10] fs/ntfs3: Add MAINTAINERS Konstantin Komarov
2021-08-09 10:56   ` David Sterba
2021-08-09 16:16     ` Konstantin Komarov
2021-08-09 16:44       ` Kari Argillander
2021-08-09 16:54         ` Randy Dunlap
2021-08-09 18:56           ` Dan Williams
2021-08-09 19:45             ` Kari Argillander
2021-07-29 16:24 ` [PATCH v27 00/10] NTFS read-write driver GPL implementation by Paragon Software Darrick J. Wong
2021-08-02  3:23   ` Theodore Ts'o
2021-08-02 15:05     ` Theodore Ts'o
2021-08-12 17:03     ` Kari Argillander
2021-08-13 15:53       ` Kari Argillander
2021-08-21 12:38     ` Yan Pashkovsky
2021-08-03 11:57 ` [PATCH] Restyle comments to better align with kernel-doc Kari Argillander
2021-08-03 13:38   ` Dan Carpenter
2021-08-03 15:26     ` Kari Argillander
2021-08-03 15:41       ` Matthew Wilcox
2021-08-30 16:10   ` Konstantin Komarov
2021-08-30 17:13     ` Kari Argillander
2021-08-10  5:46 ` [PATCH v27 00/10] NTFS read-write driver GPL implementation by Paragon Software Kari Argillander
2021-08-10  6:47   ` Darrick J. Wong

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=526c746b-2615-6a27-f753-4655571a5462@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=aaptel@suse.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=andy.lavr@gmail.com \
    --cc=anton@tuxera.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=ebiggers@kernel.org \
    --cc=hch@lst.de \
    --cc=joe@perches.com \
    --cc=kari.argillander@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    --cc=mark@harmstone.com \
    --cc=nborisov@suse.com \
    --cc=oleksandr@natalenko.name \
    --cc=pali@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH v27 07/10] fs/ntfs3: Add NTFS journal' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).