Right. The iscsi layer removes the devices that were getting accessed by
the session and this causes the scsi layer to send a sync cache command
if the device had caching on.
But the iscsi layer does not do any caching of data. It passes/sends
whatever it has when it gets it. Upper layers like filesystems or memory
layer cache data. If you were writing out data and ran the logout
command, the logout and sync cache can occur before all the writing is
done. The iscsi layer does not know what the layers above have to write
out, so the iscsi layer just kills the devices and has the scsi layer
send the sync cache when ever you run the logout command.
The user needs to make sure they have unmounted FSes or had they apps
sync their data before running the logout command.
>
> My hypothesis is thus that my problem originates from this behavior of
> the iscsiadm logout action. If I'm not wrong about that, how can i
> make it so that a synchronization is done before the iscsi logout ? Or
> I am completely wrong, and then do you have any insight as to what my
> problem really is ?
I do not think it is really a iscsiadm issue or at least there is
nothing the iscsi layer can do. It just does not know what the upper
layers are doing. The iscsi layer just handles iscsi stuff. What is in
the FS/VM/block/userspace buffers/cache at the time of the logout
command is not known to us. You need to sync your data, unmount
filesystems, etc, before you logout a session. For example when the
system shutsdown, the FSes will be unmounted and data written out, then
the iscsi service is shutdown which does the logout command.
Did you check if the target is even getting the sync cache command btw?
Some older kernels had a bug in the scsi or driver model layer where it
never got sent. Also check your cache settings and make sure the cache
is on or the sync cache does not get sent.
What FS and what mount options are you using?
If you do
- umount fs
- iscsiadm -m .... -logout
- sync
does the sync cause IO errors to get printed in /var/log/messages for
the devices that just got deleted by the iscsiadm logout command?
Usually "umount" should sync that filesystem's data, and probably wait until that finished. I don't thin that iSCSI adds another buffering layer that could hold back data between unmount and iSCSI logout.
Ulrich
What comes to my mind: Do you logout after unmount, or do you logout after SUCCESSFUL unmount? I mean: if the filesystem is busy, it won't unmount, and there will be no sync then.
if umount fs; then
iscsiadm ...
else
error
fi
>
> does the sync cause IO errors to get printed in /var/log/messages for
> the devices that just got deleted by the iscsiadm logout command?
Regards,
Ulrich
Yeah, I checked that my tgt driver received the sync when i do the
logout command, and that is the case . No problem over this side.
By the way, I work on an ubuntu 10.4 LTS, so I don't think that could
come from an old kernel version (or a too old one).
What seemed strange to me is that without the sync command, my driver
did not update many blocs/sectors on my storage, even though I did
properly umount and logout. To sum it up, I could not find where were
the lost data, and that is the reason why i came here with my
question.
Anyways, thanks for the answer, it seems i'll have to dig a little bit
more in how the FS side works to understand where is my shortcoming
then.
Thanks again :)
--
David Pineau, Etudiant Epitech -Promotion 2012-
Assistant C/Unix, Assistant Langages Avancés
Membre LSE (Laboratoire Système Epita/Epitech).
I am currently using ext2 for my tests (i tried with fat32 too, and if
i remember correctly, that was about the same for this cache matter).
About the mount options, i do not give any peculiar one, as I didnt
see the need. When i came across this problem i went through the
manual to try and find some fs-independant options that could help but
did not manage to identify any (maybe did i miss some).