From: Goffredo Baroncelli <kreijack@tiscali.it>
To: linux-btrfs@vger.kernel.org
Cc: Goffredo Baroncelli <kreijack@inwind.it>
Subject: [PATCH 0/9][btrfs-progs] Remove unused dirstream variable
Date: Sat, 9 Dec 2023 19:53:20 +0100 [thread overview]
Message-ID: <cover.1702148009.git.kreijack@inwind.it> (raw)
From: Goffredo Baroncelli <kreijack@inwind.it>
For historical reason, the helpers [btrfs_]open_[file_or_]dir() work with
directory returning the 'fd' and a 'dirstream' variable returned by
opendir(3).
If the path is a file, the 'fd' is computed from open(2) and
dirstream is set to NULL.
If the path is a directory, first the directory is opened by opendir(3), then
the 'fd' is computed using dirfd(3).
However the 'dirstream' returned by opendir(3) is left open until 'fd'
is not needed anymore.
In near every case the 'dirstream' variable is not used. Only 'fd' is
used.
A call to close_file_or_dir() freed both 'fd' and 'dirstream'.
Aim of this patch set is to getrid of this complexity; when the path of
a directory is passed, the fd is get directly using open(path, O_RDONLY):
so we don't need to use readdir(3) and to maintain the not used variable
'dirstream'.
So each call of a legacy [btrfs_]open_[file_or_]dir() helper is
replaced by a call to the new btrfs_open_[file_or_]dir_fd() functions.
These functions return only the file descriptor.
Also close_file_or_dir() is not needed anymore.
The first patch, introduces the new helpers; the last patch removed the
unused older helpers. The intermediate patches updated the code.
The 3rd patch updated also the add_seen_fsid() function. Before it
stored the dirstream variable. But now it is not needed anymore.
So we removed a parameter of the functions and a field in the structure.
In the 8th patch, the only occurrences where 'dirstream' is used was
corrected: the dirstream is computed using fdopendir(3), and the cleanup
is updated according.
The results is:
- removed 7 functions
- add 4 new functions
- removed 100 lines
- removed 43 occurrences of an unused 'dirstream' variable.
BR
G.Baroncelli
*** BLURB HERE ***
Goffredo Baroncelli (9):
Killing dirstream: add helpers
Killing dirstream: replace btrfs_open_dir with btrfs_open_dir_fd
Killing dirstream: replace btrfs_open_dir with btrfs_open_dir_fd
Killing dirstream: replace open_path_or_dev_mnt with btrfs_open_mnt_fd
Killing dirstream: replace open_file_or_dir3 with btrfs_open_fd2
Killing dirstream: replace btrfs_open_file_or_dir with
btrfs_open_file_or_dir_fd
Killing dirstream: replace open_file_or_dir with btrfs_open_fd2
Killing dirstream: remove open_file_or_dir3 from du_add_file
Killing dirstream: remove unused functions
cmds/balance.c | 27 ++++-----
cmds/device.c | 26 ++++----
cmds/filesystem-du.c | 18 +++++-
cmds/filesystem-usage.c | 5 +-
cmds/filesystem.c | 26 ++++----
cmds/inspect.c | 35 +++++------
cmds/property.c | 5 +-
cmds/qgroup.c | 29 ++++-----
cmds/quota.c | 16 +++--
cmds/replace.c | 17 +++---
cmds/scrub.c | 15 ++---
cmds/subvolume-list.c | 5 +-
cmds/subvolume.c | 44 ++++++--------
common/device-scan.c | 6 +-
common/device-scan.h | 4 +-
common/open-utils.c | 127 ++++++++++++----------------------------
common/open-utils.h | 13 ++--
common/utils.c | 5 +-
18 files changed, 164 insertions(+), 259 deletions(-)
--
2.43.0
next reply other threads:[~2023-12-09 19:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-09 18:53 Goffredo Baroncelli [this message]
2023-12-09 18:53 ` [PATCH 1/9] Killing dirstream: add helpers Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 2/9] Killing dirstream: replace btrfs_open_dir with btrfs_open_dir_fd Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 3/9] " Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 4/9] Killing dirstream: replace open_path_or_dev_mnt with btrfs_open_mnt_fd Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 5/9] Killing dirstream: replace open_file_or_dir3 with btrfs_open_fd2 Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 6/9] Killing dirstream: replace btrfs_open_file_or_dir with btrfs_open_file_or_dir_fd Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 7/9] Killing dirstream: replace open_file_or_dir with btrfs_open_fd2 Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 8/9] Killing dirstream: remove open_file_or_dir3 from du_add_file Goffredo Baroncelli
2023-12-09 18:53 ` [PATCH 9/9] Killing dirstream: remove unused functions Goffredo Baroncelli
2023-12-14 16:17 ` [PATCH 0/9][btrfs-progs] Remove unused dirstream variable David Sterba
2023-12-14 19:11 ` Goffredo Baroncelli
2023-12-30 11:20 ` Goffredo Baroncelli
2024-01-02 18:17 ` David Sterba
2024-02-07 10:16 ` David Sterba
2024-02-08 17:28 ` Goffredo Baroncelli
2024-02-08 17:34 ` Goffredo Baroncelli
2024-02-08 20:18 ` Goffredo Baroncelli
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=cover.1702148009.git.kreijack@inwind.it \
--to=kreijack@tiscali.it \
--cc=kreijack@inwind.it \
--cc=kreijack@libero.it \
--cc=linux-btrfs@vger.kernel.org \
/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