mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sungjong Seo <sjdev.seo@gmail.com>
To: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com>,
	Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	"Andy.Wu@sony.com" <Andy.Wu@sony.com>,
	"Wataru.Aoyama@sony.com" <Wataru.Aoyama@sony.com>,
	Sungjong Seo <sj1557.seo@samsung.com>
Subject: Re: [PATCH v1 1/5] exfat: reduce the size of exfat_entry_set_cache
Date: Wed, 23 Nov 2022 22:49:47 +0900	[thread overview]
Message-ID: <feeacb4c-be40-9090-1926-02cdbb6b3a15@samsung.com> (raw)
In-Reply-To: <PUZPR04MB63168831A4F57B74109A893A81069@PUZPR04MB6316.apcprd04.prod.outlook.com>

Hi, Yuezhang Mo,

> In normal, there are 19 directory entries at most for a file or
> a directory.
>   - A file directory entry
>   - A stream extension directory entry
>   - 1~17 file name directory entry
> 
> So the directory entries are in 3 sectors at most, it is enough
> for struct exfat_entry_set_cache to pre-allocate 3 bh.
> 
> This commit changes the size of struct exfat_entry_set_cache as:
> 
>                    Before   After
> 32-bit system      88       32    bytes
> 64-bit system      168      48    bytes
> 
> Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
> Reviewed-by: Andy Wu <Andy.Wu@sony.com>
> Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
> ---
>  fs/exfat/exfat_fs.h | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> index a8f8eee4937c..7d2493cda5d8 100644
> --- a/fs/exfat/exfat_fs.h
> +++ b/fs/exfat/exfat_fs.h
> @@ -9,6 +9,7 @@
>  #include <linux/fs.h>
>  #include <linux/ratelimit.h>
>  #include <linux/nls.h>
> +#include <linux/blkdev.h>
>  
>  #define EXFAT_ROOT_INO		1
>  
> @@ -41,6 +42,14 @@ enum {
>  #define ES_2_ENTRIES		2
>  #define ES_ALL_ENTRIES		0
>  
> +#define ES_FILE_ENTRY		0
> +#define ES_STREAM_ENTRY		1
> +#define ES_FIRST_FILENAME_ENTRY	2

New ES_ definitions seem to be an index in an entry set. However, this
is confusing with definitions for specifying the range used when
obtaining an entry set, such as ES_2_ENTRIES or ES_ALL_ENTRIES.
Therefore, it would be better to use ES_IDX_ instead of ES_ to
distinguish names such as ES_IDX_FILE, ES_IDX_STREAM and so on.
(If you can think of a better prefix, it doesn't have to be ES_IDX_)

> +#define EXFAT_FILENAME_ENTRY_NUM(name_len) \
> +	DIV_ROUND_UP(name_len, EXFAT_FILE_NAME_LEN)
> +#define ES_LAST_FILENAME_ENTRY(name_len)	\
> +	(ES_FIRST_FILENAME_ENTRY + EXFAT_FILENAME_ENTRY_NUM(name_len))
> +
As with the newly defined ES_ value above, it makes sense for the
ES_LAST_FILENAME_ENTRY() MACRO to return the index of the last filename
entry. So let's subtract 1 from the current MACRO.

>  #define DIR_DELETED		0xFFFF0321
>  
>  /* type values */
> @@ -68,9 +77,6 @@ enum {
>  #define MAX_NAME_LENGTH		255 /* max len of file name excluding NULL */
>  #define MAX_VFSNAME_BUF_SIZE	((MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE)
>  
> -/* Enough size to hold 256 dentry (even 512 Byte sector) */
> -#define DIR_CACHE_SIZE		(256*sizeof(struct exfat_dentry)/512+1)
> -
>  #define EXFAT_HINT_NONE		-1
>  #define EXFAT_MIN_SUBDIR	2
>  
> @@ -125,6 +131,16 @@ enum {
>  #define BITS_PER_BYTE_MASK	0x7
>  #define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1)
>  
> +/* 19 entries = 1 file entry + 1 stream entry + 17 filename entries */
> +#define ES_MAX_ENTRY_NUM	ES_LAST_FILENAME_ENTRY(MAX_NAME_LENGTH)

Of course, it needs to add 1 here.

> +
> +/*
> + * 19 entries x 32 bytes/entry = 608 bytes.
> + * The 608 bytes are in 3 sectors at most (even 512 Byte sector).
> + */
> +#define DIR_CACHE_SIZE		\
> +	(DIV_ROUND_UP(EXFAT_DEN_TO_B(ES_MAX_ENTRY_NUM), SECTOR_SIZE) + 1)
> +
>  struct exfat_dentry_namebuf {
>  	char *lfn;
>  	int lfnbuf_len; /* usually MAX_UNINAME_BUF_SIZE */
> @@ -166,11 +182,11 @@ struct exfat_hint {
>  
>  struct exfat_entry_set_cache {
>  	struct super_block *sb;
> -	bool modified;
>  	unsigned int start_off;
>  	int num_bh;
>  	struct buffer_head *bh[DIR_CACHE_SIZE];
>  	unsigned int num_entries;
> +	bool modified;
>  };
>  
>  struct exfat_dir_entry {

      parent reply	other threads:[~2022-11-23 13:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  5:46 Yuezhang.Mo
2022-11-23 13:09 ` Sungjong Seo
2022-11-23 13:24 ` Sungjong Seo
2022-11-23 13:49 ` Sungjong Seo [this message]

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=feeacb4c-be40-9090-1926-02cdbb6b3a15@samsung.com \
    --to=sjdev.seo@gmail.com \
    --cc=Andy.Wu@sony.com \
    --cc=Wataru.Aoyama@sony.com \
    --cc=Yuezhang.Mo@sony.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    /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®