linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Help! How to delete an 8094-byte PATH?
       [not found] <d4a67b38-3026-59be-06a8-3a9a5f908eb4@embecosm.com>
@ 2022-01-27 12:20 ` Ritesh Harjani
  2022-01-27 13:40   ` Matthew Wilcox
  0 siblings, 1 reply; 4+ messages in thread
From: Ritesh Harjani @ 2022-01-27 12:20 UTC (permalink / raw)
  To: Maxim Blinov; +Cc: linux-ext4, linux-fsdevel

cc'ing linux-fsdevel too.

On 22/01/27 07:06AM, Maxim Blinov wrote:
> Hi all,
>
> I'm not a subscriber to this list (so please put me in the CC), but I've
> hit a really annoying un-googleable issue that I don't know who to ask
> about.
>
> A runaway script has been recursively creating sub-directories under
> sub-directories until it hit the (apparent) OS limit. The path in
> question goes something like this:
>
> /work/build-native/binutils-gdb/gnulib/confdir3/confdir3/confdir3/confdir3/confdir3/........
> (you get the idea)
>
> It was only stopped by the following error:
> mkdir: cannot create directory 'confdir3': File name too long
>
> OK, fine, that was silly but whatever, right? I tried to delete this
> huge directory from the top with

;)

>
> rm -rf confdir3/
>
> but that simply generated the same error as above. So, I figured "Hey,

Strange. Though I didn't try creating same name subdirectories like how you have
done above i.e. confdir3 within confdir3 and recurse.
But I was able to remove the parent directory after hitting the max PATH_LEN
issue.

I ran this test below test to see if it fails on my ext4 latest tree. But this
passes. https://github.com/pjd/pjdfstest/blob/master/tests/mkdir/03.t

But just curious, by any chance did below fixes it for you?
echo 3 > /proc/sys/vm/drop_caches


-ritesh

> I'll just walk all the way to the bottom, and delete the directories
> one-by-one bottom up". Here's the script I ran to get to the bottom:
>
> $ for i in $(seq 999999); do echo "im $i levels deep"; cd confdir3; done;
>
> It then ran for a while, and eventually I got to the bottom:
>
> ```
> ...
> im 892 levels deep
> im 893 levels deep
> im 894 levels deep
> im 895 levels deep
> im 896 levels deep
> bash: cd: confdir3: File name too long
> $ ls
> <nothing here>
> ```
>
> So then, I `cd ../`, and `rmdir confdir3`, but even here, I get
>
> rmdir: failed to remove 'confdir3/': File name too long
>
> I would be very grateful if someone could please help suggest how I
> might get this infernal tower of directories off of my precious ext4
> partition.
>
> I was thinking maybe there's some kind of magic "forget this directory
> inode ever existed" command, but I am out of my depth with filesystems.
>
> Best Regards,
>
> Maxim Blinov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help! How to delete an 8094-byte PATH?
  2022-01-27 12:20 ` Help! How to delete an 8094-byte PATH? Ritesh Harjani
@ 2022-01-27 13:40   ` Matthew Wilcox
  2022-01-27 15:09     ` Maxim Blinov
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2022-01-27 13:40 UTC (permalink / raw)
  To: Ritesh Harjani; +Cc: Maxim Blinov, linux-ext4, linux-fsdevel

On Thu, Jan 27, 2022 at 05:50:39PM +0530, Ritesh Harjani wrote:
> On 22/01/27 07:06AM, Maxim Blinov wrote:
> > $ for i in $(seq 999999); do echo "im $i levels deep"; cd confdir3; done;
> >
> > It then ran for a while, and eventually I got to the bottom:
> >
> > ```
> > ...
> > im 892 levels deep
> > im 893 levels deep
> > im 894 levels deep
> > im 895 levels deep
> > im 896 levels deep
> > bash: cd: confdir3: File name too long
> > $ ls
> > <nothing here>
> > ```
> >
> > So then, I `cd ../`, and `rmdir confdir3`, but even here, I get
> >
> > rmdir: failed to remove 'confdir3/': File name too long
> >
> > I would be very grateful if someone could please help suggest how I
> > might get this infernal tower of directories off of my precious ext4
> > partition.
> >
> > I was thinking maybe there's some kind of magic "forget this directory
> > inode ever existed" command, but I am out of my depth with filesystems.

here's an idea:

while true; do
	mv confdir3/confdir3 tmpd; rmdir confdir3; mv tmpd confdir3;
done

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help! How to delete an 8094-byte PATH?
  2022-01-27 13:40   ` Matthew Wilcox
@ 2022-01-27 15:09     ` Maxim Blinov
  2022-01-27 15:34       ` Maxim Blinov
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Blinov @ 2022-01-27 15:09 UTC (permalink / raw)
  To: Matthew Wilcox, Ritesh Harjani; +Cc: linux-ext4, linux-fsdevel

Hi Matthew, Ritesh,

On 27/01/2022 13:40, Matthew Wilcox wrote:
> here's an idea:
> 
> while true; do
> 	mv confdir3/confdir3 tmpd; rmdir confdir3; mv tmpd confdir3;
> done
> 

Thankyou for all your comments - mv'ing a child directory "up" and
deleting *that* did the trick!

Infact I was complaining about this to some colleagues who kindly
pointed me to this thread [1] where someone has exactly the same issue.

Searching for `confdir3`, it turns out this issue is more googleable
than I initially realized - there's quite a few others who have bumped
into these weird path length limitations, in particular with docker
(there's another thing I forgot to mention - to be clear, I'm running
QEMU inside a docker container.)

Still it seems strange, since the QEMU VM disk image is a static file
within the docker file system, and there are no bind mounts going on in
the container.

[1]: https://github.com/moby/moby/issues/13451

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help! How to delete an 8094-byte PATH?
  2022-01-27 15:09     ` Maxim Blinov
@ 2022-01-27 15:34       ` Maxim Blinov
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Blinov @ 2022-01-27 15:34 UTC (permalink / raw)
  To: Matthew Wilcox, Ritesh Harjani; +Cc: linux-ext4, linux-fsdevel

...Oh dear, I think I may have been extremely stupid: This entire time I
thought I was typing into the QEMU VM, but in actual fact I was typing
into the docker container that contained it.

So this wasn't an ext4 issue at all, but a limitation of whatever
filesystem docker containers use.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-27 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <d4a67b38-3026-59be-06a8-3a9a5f908eb4@embecosm.com>
2022-01-27 12:20 ` Help! How to delete an 8094-byte PATH? Ritesh Harjani
2022-01-27 13:40   ` Matthew Wilcox
2022-01-27 15:09     ` Maxim Blinov
2022-01-27 15:34       ` Maxim Blinov

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).