Why so much duplication *_read_inode()?

Why so much duplication *_read_inode()?

Post by Brian McCaule » Sat, 31 Oct 1998 04:00:00



This is in the category of "something that's been bugging me for some
time".  It doesn't really matter I'd just like to know if there's a
reason (other than intertia) why the same bit of code appears all over
the place.

In EXT2:
        else if (S_ISCHR(inode->i_mode))
                inode->i_op = &chrdev_inode_operations;
        else if (S_ISBLK(inode->i_mode))
                inode->i_op = &blkdev_inode_operations;
        else if (S_ISFIFO(inode->i_mode))
                init_fifo(inode);

In NFS:

        else if (S_ISCHR(inode->i_mode))
                inode->i_op = &chrdev_inode_operations;
        else if (S_ISBLK(inode->i_mode))
                inode->i_op = &blkdev_inode_operations;
        else if (S_ISFIFO(inode->i_mode)) {
                if (was_empty)
                        init_fifo(inode);
In MINIX:

        else if (S_ISCHR(inode->i_mode))
                inode->i_op = &chrdev_inode_operations;
        else if (S_ISBLK(inode->i_mode))
                inode->i_op = &blkdev_inode_operations;
        else if (S_ISFIFO(inode->i_mode))
                init_fifo(inode);

And so on...

Why is this stuff not simply in read_inode() in
/usr/src/linux/fs/inode.c something like this?

static inline void read_inode(struct inode * inode)
{
        lock_inode(inode);
        if (inode->i_sb && inode->i_sb->s_op && inode->i_sb->s_op->read_inode)
                inode->i_sb->s_op->read_inode(inode);
        if (!inode->i_op) {
          if (S_ISCHR(inode->i_mode))
                inode->i_op = &chrdev_inode_operations;
          if (S_ISBLK(inode->i_mode))
                inode->i_op = &blkdev_inode_operations;
          if (S_ISFIFO(inode->i_mode))
                init_fifo(inode);
        }
        unlock_inode(inode);

Quote:}

--

  .  _\\__[oo   faeces from    | Phones: +44 121 471 3789 (home)

 .  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
  # ll  l\\  ~~~~ ~   ~ ~    ~ | http://www.wcl.bham.ac.uk/~bam/
 ###LL  LL\\ (Brian McCauley)  |
 
 
 

1. Telnet & FTP lag - why why why???

Hi,

    We've been experiencing a *very annoying* FTP and Telnet lag over
our PPP connection to a NetBlazer at our downstream ISP.

This only occurs when FTP'ing or Telnetting *OUT* from this side of the
 PPP connection. This does NOT occur on incoming connections, and this
is not simply a "traffic issue".

We also run pppd for dialin clients, and there is no Telnet/FTP lag to
and from our dial-in clients. It only occurs over our "backbone"
connection to our ISP.

I have tried changing the mtu/mru to 296 - no change. I have tried the
-mru option, no change. Note that there is no lag when using other
protocols such as http.

We are running 1.1.54 and ppp-2.1.2b, a 115k 28.8 connection from the
linux box to a Netblazer, using Hayes Optima 288s.

Anyone who can fix or with similar experience, please reply.
Pat
--------------------------------------------------------
"Free the Internet" - interpret at will.
Visit Whistler, B.C, at http://www.whistler.net/ !
(currently a SLOW link, but not for long!)

--------------------------------------------------------

2. NIS and Shadow Password

3. Why, Why Why

4. Problems with cdrite and Philips CDD 2000

5. WHY-WHY-WHY.....my Mitsumi CD don't seek at boot??!!!!!

6. search for files in subdir

7. Why, Why Why

8. Counter

9. Random IP Masq crash, WHY, WHY, WHY?

10. Why Why Why? snoop question on ppp interface..

11. hard drive duplication

12. sys32_ioctl: kill code duplication

13. Perfect Duplication of Data from one disk to aother