All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zach Brown <zab@zabbo.net>
To: Valerie Aurora <val@versity.com>
Cc: rpdfs-devel@lists.linux.dev
Subject: Re: [PATCH 2/2] Add rpdfs_rmdir()
Date: Wed, 25 Feb 2026 15:10:20 -0800	[thread overview]
Message-ID: <20260225231020.GE2876476@localhost.localdomain> (raw)
In-Reply-To: <20260224164157.2591-3-val@versity.com>

On Tue, Feb 24, 2026 at 05:41:57PM +0100, Valerie Aurora wrote:
> Copied from rpdfs_rename() and the extra bits removed.

...

> +	/* update vfs inodes: first dir sizes and times */
> +	i_size_write(dir, i_size_read(dir) - dentry->d_name.len);
> +	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
> +
> +	/* now inode nlink and times */
> +	if (inode->i_nlink < 2)
> +		pr_warn("deleting dir %.*s with link count %d < 2",
> +			dentry->d_name.len, dentry->d_name.name, inode->i_nlink);

I'm not sure how I feel about this warning.  I could see just not
bothering to warn about inconsistency, like we did up there with the
i_size_write() changing a possibly bad existing size.  If we warned we'd
probably want to show the inode number of the dir and inode?  Otherwise
it doesn't seem particularly helpful.

(Eventually we'll probably want a warning wrapper in pr.h that shows some
indication of which fs as well, like the sb_id for debugging.  But
nothing yet.)

Definitely don't print names on the console, though.  They can be
sensitive or absolute nonsense.  255 ascii bells :).

But more importantly..

> +	else
> +		clear_nlink(inode);

_unlink() and _rmdir() are identical, except for the magic silly decrease of
nlink on behalf of . and .. when the inode is a dir.  It looks like this
gets the inode nlink dec right, but misses the dec of the parent nlink.
Oh, and I guess testing that the dir is empty or returning ENOTEMPTY.

Instead of having two copies, just have unlink use S_ISDIR for the dir
differences.  Then the .rmdir and .unlink ops can both point to unlink.

- z 

      reply	other threads:[~2026-02-25 23:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 16:41 [PATCH 0/2] linux-rpdfs: rmdir() and unlink() Valerie Aurora
2026-02-24 16:41 ` [PATCH 1/2] Add rpdfs_unlink() Valerie Aurora
2026-02-24 16:41 ` [PATCH 2/2] Add rpdfs_rmdir() Valerie Aurora
2026-02-25 23:10   ` Zach Brown [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=20260225231020.GE2876476@localhost.localdomain \
    --to=zab@zabbo.net \
    --cc=rpdfs-devel@lists.linux.dev \
    --cc=val@versity.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.