public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Question for XFS (mounting and clean bit)
@ 2008-05-27 16:13 Andre Nitschke
  2008-05-28 22:21 ` Martin Steigerwald
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andre Nitschke @ 2008-05-27 16:13 UTC (permalink / raw)
  To: xfs

Hello,
i am a Linux User from Germany and chanched to xfs. I use Debian 4 and the
installer creates lilo. Because of a wrong configuration i destroyed the
lilo.conf and rebootet with a systemrescuecd. from here i mount the xfs
partition and try to run lilo, but it fails.
then i had a realy bad idea. i unmount the xfs partition and then mount it as
root, but there exit a root file system.
i type
mount /dev/sda2 /
no error appears. i could not access the partiton from the hdd, only see the
tmpfs from the live-boot cd. hm
i type mount and the mount command says:
tmpfs on / as tmpfs (rw)
....(some entrys...)
/dev/sda2 on / as xfs (rw)
ok, both devices were mountet as /
but i could only access the tmpfs system from the live cd.
i try to reboot. the system sends the term and kill signal, then hang up.
nothing happesn.
i press reset.
then linux startet normal and says ...

 XFS mounting filesystem sda2
 Ending clean XFS mount for filesystem: sda2

so i think nothing should happens to the xfs.
but i cant stop thinking, go to my testpc with linux and xfs and create the same
situtation. everytime ... clean xfs.
when i start writing data and then press reset comes this message:

 SGI XFS Quota Management subsystem
 XFS mounting filesystem hda2
 Starting XFS recovery on filesystem: hda2 (logdev: internal)
 Ending XFS recovery on filesystem: hda2 (logdev: internal)

i have two questions. first, is the xfs on my working-machine damaged by my bad
idea mounting two devices as root
and secound, is the clean bit removed when mounting a xfs or when i first write
data on it?

thanks

andre

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

* Re: Question for XFS (mounting and clean bit)
  2008-05-27 16:13 Question for XFS (mounting and clean bit) Andre Nitschke
@ 2008-05-28 22:21 ` Martin Steigerwald
  2008-05-29  6:59 ` Timothy Shimmin
  2008-05-29  8:02 ` Martin Steigerwald
  2 siblings, 0 replies; 7+ messages in thread
From: Martin Steigerwald @ 2008-05-28 22:21 UTC (permalink / raw)
  To: linux-xfs


Hi Andre,

Am Dienstag 27 Mai 2008 schrieb Andre Nitschke:
> Hello,
> i am a Linux User from Germany and chanched to xfs. I use Debian 4 and
> the installer creates lilo. Because of a wrong configuration i
> destroyed the lilo.conf and rebootet with a systemrescuecd. from here i
> mount the xfs partition and try to run lilo, but it fails.
> then i had a realy bad idea. i unmount the xfs partition and then mount
> it as root, but there exit a root file system.

[...]

> i have two questions. first, is the xfs on my working-machine damaged
> by my bad idea mounting two devices as root
> and secound, is the clean bit removed when mounting a xfs or when i
> first write data on it?

Mounting two devices on / should not harm the XFS filesystem in itself. I 
even think that also new files created from within the already running 
part of the live distribution should go to the initially mounted root 
filesystem (if the live distro creates new files in there at all). But I 
am not completely sure on that.

Anyway, there are two ways to check: xfs_check or xfs_repair -n

I do not know an answer to you second question. But when atime updates are 
enabled you usually have your first write pretty soon.

Ciao,
-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

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

* Re: Question for XFS (mounting and clean bit)
  2008-05-27 16:13 Question for XFS (mounting and clean bit) Andre Nitschke
  2008-05-28 22:21 ` Martin Steigerwald
@ 2008-05-29  6:59 ` Timothy Shimmin
  2008-05-29  8:09   ` Martin Steigerwald
  2008-05-29  8:02 ` Martin Steigerwald
  2 siblings, 1 reply; 7+ messages in thread
From: Timothy Shimmin @ 2008-05-29  6:59 UTC (permalink / raw)
  To: Andre Nitschke; +Cc: xfs

Hi Andre,

I didn't follow all of this, sorry.
When you ask about the "clean bit", I assume that you are referring
to "clean XFS mount for filesystem".
We effectively mark it clean if we do a successful unmount.
As part of unmount, we write an unmount record into the xfs log.
On the next mount we look for the head of the log and then for the
unmount record nearby. If we find the unmount record then we know
we have had a clean unmount previously, otherwise we replay the log.
So it's really a question of doing an unmount versus resetting the
box beforehand or forcing a shutdown beforehand.
I guess the other question would be if it is possible to mount
the filesystem and try to do no write i/o such that the ondisk log
is not touched at all since the last unmount.
I believe so. You can use "xfs_logprint -t" to see if the head
has moved and it is clean or not etc..
IIRC we did have an sb counters thing recently where in an idle state
we were logging the super block counters - Dave (dgc) fixed this one.

--Tim

Andre Nitschke wrote:
> Hello,
> i am a Linux User from Germany and chanched to xfs. I use Debian 4 and the
> installer creates lilo. Because of a wrong configuration i destroyed the
> lilo.conf and rebootet with a systemrescuecd. from here i mount the xfs
> partition and try to run lilo, but it fails.
> then i had a realy bad idea. i unmount the xfs partition and then mount it as
> root, but there exit a root file system.
> i type
> mount /dev/sda2 /
> no error appears. i could not access the partiton from the hdd, only see the
> tmpfs from the live-boot cd. hm
> i type mount and the mount command says:
> tmpfs on / as tmpfs (rw)
> ....(some entrys...)
> /dev/sda2 on / as xfs (rw)
> ok, both devices were mountet as /
> but i could only access the tmpfs system from the live cd.
> i try to reboot. the system sends the term and kill signal, then hang up.
> nothing happesn.
> i press reset.
> then linux startet normal and says ...
> 
>  XFS mounting filesystem sda2
>  Ending clean XFS mount for filesystem: sda2
> 
> so i think nothing should happens to the xfs.
> but i cant stop thinking, go to my testpc with linux and xfs and create the same
> situtation. everytime ... clean xfs.
> when i start writing data and then press reset comes this message:
> 
>  SGI XFS Quota Management subsystem
>  XFS mounting filesystem hda2
>  Starting XFS recovery on filesystem: hda2 (logdev: internal)
>  Ending XFS recovery on filesystem: hda2 (logdev: internal)
> 
> i have two questions. first, is the xfs on my working-machine damaged by my bad
> idea mounting two devices as root
> and secound, is the clean bit removed when mounting a xfs or when i first write
> data on it?
> 
> thanks
> 
> andre
> 
> 

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

* Re: Question for XFS (mounting and clean bit)
  2008-05-27 16:13 Question for XFS (mounting and clean bit) Andre Nitschke
  2008-05-28 22:21 ` Martin Steigerwald
  2008-05-29  6:59 ` Timothy Shimmin
@ 2008-05-29  8:02 ` Martin Steigerwald
  2008-05-29  8:04   ` Martin Steigerwald
  2 siblings, 1 reply; 7+ messages in thread
From: Martin Steigerwald @ 2008-05-29  8:02 UTC (permalink / raw)
  To: linux-xfs

Am Dienstag 27 Mai 2008 schrieb Andre Nitschke:
> Hello,
> i am a Linux User from Germany and chanched to xfs. I use Debian 4 and
> the installer creates lilo. Because of a wrong configuration i
> destroyed the lilo.conf and rebootet with a systemrescuecd. from here i
> mount the xfs partition and try to run lilo, but it fails.
> then i had a realy bad idea. i unmount the xfs partition and then mount
> it as root, but there exit a root file system.

Hi Andre!

Some additional hint on this:

I think what you actually wanted to do was:

mount /dev/sda1 /mnt
chroot /mnt
lilo
Ctrl-D

I.e. you use chroot to change a directory temporarily and only for all 
subsequent commands in the same console session to /.

> i have two questions. first, is the xfs on my working-machine damaged
> by my bad idea mounting two devices as root
> and secound, is the clean bit removed when mounting a xfs or when i
> first write data on it?

Also here some clarification and confirmation on my previous statement:

I believe that a new mount is only seen by process that enter the mount 
point directory after the mount has been done. I think that all the 
processes that are working already in that directory or a sub directory 
of it will still see the situation before the mount.

Lets try this out:

Shell 1:

/mnt/zeit is on the / filesystem:

martin@shambala:~ -> cd /mnt/zeit
martin@shambala:/mnt/zeit -> ls -lid .
89142 drwxr-xr-x 2 root root 6 2008-01-28 14:35 .

Shell 2:

I mount a filesystem on top of it:

root@shambala:~ -> mount /dev/shambala/lugcamp2008 /mnt/zeit
root@shambala:~ -> cd /mnt/zeit
root@shambala:/mnt/zeit -> ls -lid .
128 drwxrwxr-x 3 root martin 18 2008-05-04 00:32 .

128 appears to be the root inode (/) of the XFS filesystem in question.

But see Shell 1 again:

martin@shambala:/mnt/zeit -> ls -lid .
89142 drwxr-xr-x 2 root root 6 2008-01-28 14:35 .

Get the picture? Shell 1 still sees the old inode.

Shell 2:

Lets create a file in there:
root@shambala:/mnt/zeit -> touch fs1

And now shell 3:

Mount another filesystem on top of the same directory:

root@shambala:/mnt/zeit -> ls -lid .
128 drwxr-xr-x 24 root root 4096 2008-05-24 20:57 .
root@shambala:/mnt/zeit -> LANG=EN stat fs1
stat: cannot stat `fs1': No such file or directory
root@shambala:/mnt/zeit -> stat fs1
root@shambala:/mnt/zeit -> touch fs2

I get the same root inode number (since /dev/sda1 is a XFS filesystem as 
well which happens to use 128 as root inode number), but the file "fs1" 
is not there anymore, so this is clearly a different filesystem.

Back to shell 2:

It still sees fs1, but not fs2:

root@shambala:/mnt/zeit -> LANG=EN stat fs2
stat: cannot stat `fs2': No such file or directory

root@shambala:/mnt/zeit -> LANG=EN stat fs1
  File: `fs1'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty 
file
Device: fd00h/64768d    Inode: 184442      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2008-05-29 09:45:58.754469708 +0200
Modify: 2008-05-29 09:45:58.754469708 +0200
Change: 2008-05-29 09:45:58.754469708 +0200

Back to shell 1:

It still sees neither fs1 or fs2, but the inode before the first mount has 
happened:

martin@shambala:/mnt/zeit -> ls -lid .
89142 drwxr-xr-x 2 root root 6 2008-01-28 14:35 .

martin@shambala:/mnt/zeit -> LANG=EN stat fs1 fs2
stat: cannot stat `fs1': No such file or directory
stat: cannot stat `fs2': No such file or directory

But now lets CD out of the directory and back in again:

martin@shambala:/mnt/zeit -> ls -lid .
128 drwxr-xr-x 24 root root 4096 2008-05-29 09:47 .
martin@shambala:/mnt/zeit -> LANG=EN stat fs1 fs2
stat: cannot stat `fs1': No such file or directory
  File: `fs2'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty 
file
Device: 801h/2049d      Inode: 75339       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2008-05-29 09:47:58.090807158 +0200
Modify: 2008-05-29 09:47:58.090807158 +0200
Change: 2008-05-29 09:47:58.090807158 +0200

*Now* it sees the current situation of the second mount.

Back to shell 2:

While shell 2 still sees the situation of the first mount:

root@shambala:/mnt/zeit -> LANG=EN stat fs1 fs2
  File: `fs1'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty 
file
Device: fd00h/64768d    Inode: 184442      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2008-05-29 09:45:58.754469708 +0200
Modify: 2008-05-29 09:45:58.754469708 +0200
Change: 2008-05-29 09:45:58.754469708 +0200
stat: cannot stat `fs2': No such file or directory

Even when I start a new shell, it still sees the first mount cause it 
inherits the namespace from its parent process:

root@shambala:/mnt/zeit -> bash
root@shambala:/mnt/zeit -> LANG=EN stat fs1 fs2
  File: `fs1'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty 
file
Device: fd00h/64768d    Inode: 184442      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2008-05-29 09:45:58.754469708 +0200
Modify: 2008-05-29 09:45:58.754469708 +0200
Change: 2008-05-29 09:45:58.754469708 +0200
stat: cannot stat `fs2': No such file or directory

Only a change out of the mount point directory updates the view of the 
process:

root@shambala:/mnt -> cd zeit
root@shambala:/mnt/zeit -> LANG=EN stat fs1 fs2
stat: cannot stat `fs1': No such file or directory
  File: `fs2'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty 
file
Device: 801h/2049d      Inode: 75339       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2008-05-29 09:47:58.090807158 +0200
Modify: 2008-05-29 09:47:58.090807158 +0200
Change: 2008-05-29 09:47:58.090807158 +0200


Confused? ;-) Then I suggest playing around with this a bit. But with a 
different directory than / ;-)

That shown I I think that only processes you started *after* your second 
mount will have seen the XFS fileystem you mounted. So the only thing I 
think that might have happened is that a process that you started in your 
shell *after* you did the mount has written something to the XFS 
filesystem.

And in either case I am quite sure that nothing of all of this could 
actually have corrupted your XFS filesystem.

Ciao,
-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

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

* Re: Question for XFS (mounting and clean bit)
  2008-05-29  8:02 ` Martin Steigerwald
@ 2008-05-29  8:04   ` Martin Steigerwald
  0 siblings, 0 replies; 7+ messages in thread
From: Martin Steigerwald @ 2008-05-29  8:04 UTC (permalink / raw)
  To: linux-xfs

Am Donnerstag 29 Mai 2008 schrieb Martin Steigerwald:
> Am Dienstag 27 Mai 2008 schrieb Andre Nitschke:
> > Hello,
> > i am a Linux User from Germany and chanched to xfs. I use Debian 4
> > and the installer creates lilo. Because of a wrong configuration i
> > destroyed the lilo.conf and rebootet with a systemrescuecd. from here
> > i mount the xfs partition and try to run lilo, but it fails.
> > then i had a realy bad idea. i unmount the xfs partition and then
> > mount it as root, but there exit a root file system.
>
> Hi Andre!
>
> Some additional hint on this:
>
> I think what you actually wanted to do was:
>
> mount /dev/sda1 /mnt

mount /dev/sda2 /mnt

but you get the picture. ;)

> chroot /mnt
> lilo
> Ctrl-D

-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

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

* Re: Question for XFS (mounting and clean bit)
  2008-05-29  6:59 ` Timothy Shimmin
@ 2008-05-29  8:09   ` Martin Steigerwald
  2008-05-30  5:58     ` Timothy Shimmin
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Steigerwald @ 2008-05-29  8:09 UTC (permalink / raw)
  To: linux-xfs

Am Donnerstag 29 Mai 2008 schrieb Timothy Shimmin:
> Hi Andre,

Hi Timothy,

> I didn't follow all of this, sorry.
> When you ask about the "clean bit", I assume that you are referring
> to "clean XFS mount for filesystem".
> We effectively mark it clean if we do a successful unmount.
> As part of unmount, we write an unmount record into the xfs log.
> On the next mount we look for the head of the log and then for the
> unmount record nearby. If we find the unmount record then we know
> we have had a clean unmount previously, otherwise we replay the log.
> So it's really a question of doing an unmount versus resetting the
> box beforehand or forcing a shutdown beforehand.

But when is it dirtied? If the clean log entry is the actual "clean bit" I 
guess: When the first new entry is written in the log.

Does XFS write a log entry on mounting it already or only on the first 
real write? Or in other words if I mount a XFS filesystem without writing 
to it and reset the machine, would it be marked clean or dirty then? 
Hmmm, I could test this ;-).

If its only mounted read only, it shouldn't be marked dirty anyways.

Ciao,
-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

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

* Re: Question for XFS (mounting and clean bit)
  2008-05-29  8:09   ` Martin Steigerwald
@ 2008-05-30  5:58     ` Timothy Shimmin
  0 siblings, 0 replies; 7+ messages in thread
From: Timothy Shimmin @ 2008-05-30  5:58 UTC (permalink / raw)
  To: Martin Steigerwald; +Cc: linux-xfs

Martin Steigerwald wrote:
> Am Donnerstag 29 Mai 2008 schrieb Timothy Shimmin:
>> Hi Andre,
> 
> Hi Timothy,
> 
>> I didn't follow all of this, sorry.
>> When you ask about the "clean bit", I assume that you are referring
>> to "clean XFS mount for filesystem".
>> We effectively mark it clean if we do a successful unmount.
>> As part of unmount, we write an unmount record into the xfs log.
>> On the next mount we look for the head of the log and then for the
>> unmount record nearby. If we find the unmount record then we know
>> we have had a clean unmount previously, otherwise we replay the log.
>> So it's really a question of doing an unmount versus resetting the
>> box beforehand or forcing a shutdown beforehand.
> 
> But when is it dirtied? If the clean log entry is the actual "clean bit" I 
> guess: When the first new entry is written in the log.
> 
Yes.
As soon as the first new entry is written in the log it will effectively
change the head of the log.
The head of the log can basically be seen (simplified version) at the
change of cycle#s of the 512byte sectors of the log (each sector is encoded
with a cycle# at or near the start; the cycle# is the number of times
that we have wrapped the log).
e.g.     5 5 5 5 5 5 4 4 4 4 4
                   ^head
(we actually typically have a set of 8 log buffers that have writes issued on so
 there could easily be bumps in the example....5 5 4 4 5 4 4 etc..)
When we find the head we scan back for the start of a log record
and look for the unmount record and so we'd have
a problem if we don't find one and then we'd know it is dirty.


> Does XFS write a log entry on mounting it already or only on the first 
> real write? Or in other words if I mount a XFS filesystem without writing 
> to it and reset the machine, would it be marked clean or dirty then? 
> Hmmm, I could test this ;-).
> 
I believe it will be clean and I tried it out too :)

--Tim

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

end of thread, other threads:[~2008-05-30  5:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-27 16:13 Question for XFS (mounting and clean bit) Andre Nitschke
2008-05-28 22:21 ` Martin Steigerwald
2008-05-29  6:59 ` Timothy Shimmin
2008-05-29  8:09   ` Martin Steigerwald
2008-05-30  5:58     ` Timothy Shimmin
2008-05-29  8:02 ` Martin Steigerwald
2008-05-29  8:04   ` Martin Steigerwald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox