Re: How to safely access inode/dentry obtained from struct page *?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 30-Aug-2014 10:49 AM, "Joshi" <joshiiitr@xxxxxxxxx> wrote:
>
> I am trying to obtain file name at block layer level (above IO scheduler).
> At this level I receive bio structure, within which page pointers are kept.
>
> Thereby I do following to obtain the inode and dentry -
>
> struct inode *inode_ptr = page->mapping->host;
> if (inode_ptr != NULL)
> /* Access dentry i.e. i_dentry in the inode */
>

Are you doing this in readpage(s) or writepage(s) callback? If that's the case your page would be locked and dentry/inode wouldn't go away.

If you are doing something else then first make sure you do lock_page and proceed only if you get that page lock.

Second you can try dget and dput before you start working with dentry.

>
> This works usually. But problem is, inode and dentry may get released
> from inode and dentry cache at any time.
> While accessing inode/dentry I need to ensure that till the time I am
> accessing'em these structure remain valid in memory.
> Is it possible to ensure that? Which structures/locks I need to check
> for the purpose.

is this your observation from your test case? Can you explain your test case a bit.
>
> Appreciate any help.
>
> Thanks!
>
> --
> Joshi
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux