Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrey Albershteyn <aalbersh@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 09/10] libfrog: improve ramdisk handling in platform_flush_device
Date: Fri, 25 Sep 2026 15:47:20 -0700	[thread overview]
Message-ID: <20260925224720.GX2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260925051336.2997014-10-hch@lst.de>

On Fri, Sep 25, 2026 at 07:12:55AM +0200, Christoph Hellwig wrote:
> The ramdisk driver was quirky for BLKFLSBUF, but there never was
> any reason to skip the fsync.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  copy/xfs_copy.c    |  2 +-
>  libfrog/linux.c    | 13 ++++++-------
>  libfrog/platform.h |  2 +-
>  libxfs/init.c      |  2 +-
>  libxfs/rdwr.c      |  6 ++++--
>  5 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
> index 5435c87dba38..4692a4ffb961 100644
> --- a/copy/xfs_copy.c
> +++ b/copy/xfs_copy.c
> @@ -141,7 +141,7 @@ check_errors(void)
>  
>  	for (i = 0; i < num_targets; i++)  {
>  		if (target[i].state != INACTIVE) {
> -			if (platform_flush_device(target[i].fd, 0)) {
> +			if (platform_flush_device(target[i].fd)) {
>  				target[i].error = errno;
>  				target[i].state = INACTIVE;
>  				target[i].err_type = 2;
> diff --git a/libfrog/linux.c b/libfrog/linux.c
> index 46a5ff39e2eb..5c0d3ed7e935 100644
> --- a/libfrog/linux.c
> +++ b/libfrog/linux.c
> @@ -152,15 +152,11 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize,
>   */
>  int
>  platform_flush_device(
> -	int		fd,
> -	dev_t		device)
> +	int		fd)
>  {
>  	struct stat	st;
>  	int		ret;
>  
> -	if (major(device) == RAMDISK_MAJOR)
> -		return 0;
> -
>  	ret = fsync(fd);
>  	if (ret)
>  		return ret;
> @@ -169,9 +165,12 @@ platform_flush_device(
>  	if (ret)
>  		return ret;
>  
> -	if (S_ISBLK(st.st_mode))
> +	/*
> +	 * Historically the ram disk driver destroyed all data when BLKFLSBUF
> +	 * was called.  That has been fixed a long time, but still be careful.
> +	 */
> +	if (S_ISBLK(st.st_mode) && major(st.st_rdev) != RAMDISK_MAJOR)
>  		return ioctl(fd, BLKFLSBUF, 0);

BLKFLSBUF support on ramdisks hasn't been in the kernel since commit
ff26956875c2f0 ("brd: remove support for BLKFLSBUF") which was merged in
4.10 in late 2016.  Maybe we should remove it?

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> -
>  	return 0;
>  }
>  
> diff --git a/libfrog/platform.h b/libfrog/platform.h
> index 20f9bdf5ce5b..39d558f08629 100644
> --- a/libfrog/platform.h
> +++ b/libfrog/platform.h
> @@ -12,7 +12,7 @@ int platform_check_ismounted(char *path, char *block, struct stat *sptr,
>  int platform_check_iswritable(char *path, char *block, struct stat *sptr);
>  void platform_set_blocksize(int fd, char *path, dev_t device, int bsz,
>  		bool fatal);
> -int platform_flush_device(int fd, dev_t device);
> +int platform_flush_device(int fd);
>  int platform_direct_blockdev(void);
>  int platform_align_blockdev(void);
>  unsigned long platform_physmem(void);	/* in kilobytes */
> diff --git a/libxfs/init.c b/libxfs/init.c
> index 5a4b255165ab..4c71027d2805 100644
> --- a/libxfs/init.c
> +++ b/libxfs/init.c
> @@ -172,7 +172,7 @@ libxfs_device_close(
>  {
>  	int			ret;
>  
> -	ret = platform_flush_device(dev->fd, dev->dev);
> +	ret = platform_flush_device(dev->fd);
>  	if (ret) {
>  		ret = -errno;
>  		fprintf(stderr,
> diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
> index 837288be0307..33a0d144a1aa 100644
> --- a/libxfs/rdwr.c
> +++ b/libxfs/rdwr.c
> @@ -1112,8 +1112,10 @@ libxfs_blkdev_issue_flush(
>  	if (btp->bt_dev == 0)
>  		return 0;
>  
> -	ret = platform_flush_device(btp->bt_fd, btp->bt_dev);
> -	return ret ? -errno : 0;
> +	ret = platform_flush_device(btp->bt_fd);
> +	if (ret)
> +		return -errno;
> +	return 0;
>  }
>  
>  /*
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-09-25 22:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25  5:12 fix missing RT detection in libxfs v2 Christoph Hellwig
2026-09-25  5:12 ` [PATCH 01/10] libxfs: refactor the reinit case in libxfs_buftarg_init Christoph Hellwig
2026-09-25 22:32   ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 02/10] libxfs: split error injection option parsing out of libxfs_buftarg_init Christoph Hellwig
2026-09-25 22:33   ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 03/10] libxfs: remove buftarg member aliases Christoph Hellwig
2026-09-25  5:12 ` [PATCH 04/10] libxfs: unify buftarg handling with the kernel Christoph Hellwig
2026-09-25 22:37   ` Darrick J. Wong
2026-09-26  5:59     ` Christoph Hellwig
2026-09-27 15:18       ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 05/10] libxfs: make the size check in rtmount_init internal RT device aware Christoph Hellwig
2026-09-25 22:38   ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 06/10] libxfs: don't clear ->dev in libxfs_device_close Christoph Hellwig
2026-09-25 22:39   ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 07/10] libxfs: fix buftarg initialization for the RT device Christoph Hellwig
2026-09-25 22:42   ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 08/10] libxfs: rename bt_bdev* Christoph Hellwig
2026-09-25 22:43   ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 09/10] libfrog: improve ramdisk handling in platform_flush_device Christoph Hellwig
2026-09-25 22:47   ` Darrick J. Wong [this message]
2026-09-26  6:02     ` Christoph Hellwig
2026-09-27 15:22       ` Darrick J. Wong
2026-09-25  5:12 ` [PATCH 10/10] xfs_db: remove a double-whitespace in rdump_regfile_data Christoph Hellwig
2026-09-25 22: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=20260925224720.GX2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@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