mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Anders Karlsson <anders.karlsson@meansolutions.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: FS Structs
Date: Fri, 04 May 2001 15:07:36 +0100	[thread overview]
Message-ID: <5.1.0.14.2.20010504144007.00a12ec0@pop.cus.cam.ac.uk> (raw)
In-Reply-To: <20010503222904.A505@inspiron.ssd.hursley.ibm.com>

At 22:29 03/05/01, Anders Karlsson wrote:
>I am not subscribed to the list, so if I could be CC'd on eventual
>replies I would be grateful.

Sure.

>I have a question regarding some of the parts of the overall
>filesystem structure in the 2.4 kernel. (Kernel 2.4.[34].)
>In the file fs/super.c the structure `sb' is used, that is the
>superblock. As a part of that structure (reference include/linux/fs.h)
>is `struct list_head s_locked_inodes;'.
>
>The thing I can not understand at the moment is the `struct list_head'
>(reference include/linux/list.h) which looks very odd. How can I find
>which inodes are in the `s_locked_inodes' list?? All I want to do is
>to loop through the list and see each open inode in turn, is there any
>documentation for this, or is there any helpful soul out there that
>could give me any pointers?

This is how Linux kernel implements generic, circular, doubly-linked lists. 
The struct list_head is used both as the beginning of the list - i.e. for 
example sb->s_dirty is the beginning of the list of dirty inodes - and also 
as the anchor into the list of each dirty inode - i.e. looking at the 
struct inode it contains a field struct list_head i_list. This is the 
anchor into the list.

To walk the list you usually use list_for_each(). In the above example you 
would use:

struct list_head *tmp;
struct inode *ino;

list_for_each(tmp, &sb->s_dirty) {
         ino = list_entry(tmp, struct inode, i_list);
         /* do what you want with the inode */
}

If that wasn't clear enough you should consider reading up on this subject. 
For example "Linux Kernel Internals" contains a chapter on the Linux kernel 
linked list implementation. The URL for the online version 
is:  http://www.moses.uklinux.net/patches/lki.html

Hope this helps,

         Anton


-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://sourceforge.net/projects/linux-ntfs/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/


      reply	other threads:[~2001-05-04 14:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-03 21:29 Anders Karlsson
2001-05-04 14:07 ` Anton Altaparmakov [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=5.1.0.14.2.20010504144007.00a12ec0@pop.cus.cam.ac.uk \
    --to=aia21@cam.ac.uk \
    --cc=anders.karlsson@meansolutions.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®