Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1254626
  • 博文数量: 168
  • 博客积分: 3483
  • 博客等级: 中校
  • 技术积分: 1696
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-06 13:17
文章分类

全部博文(168)

文章存档

2015年(6)

2014年(9)

2013年(47)

2012年(11)

2011年(13)

2010年(18)

2009年(11)

2008年(42)

2007年(11)

分类: LINUX

2013-05-31 19:52:58

1. rpc.idmapd  (userspace daemon as  server)
    nfs-utils/utils/idmap.c:  nfscb(), nfsdcb()
       check  /proc/net/rpc/nfs4.idtoname/channel
                     /proc/net/rpc/nfs4.nametoid/channel       event,
        read() request of idmap_msg &&
        imconv() &&
        write() reply

2. the client of rpc.idmapd is  {NFSv4 kernel client and server}
    fs/nfs/nfsd/nfs4imapd.c:
    static struct cache_detail idtoname_cache_template = { .name           = "nfs4.idtoname", };
    static struct cache_detail nametoid_cache_template = { .name           = "nfs4.nametoid", };
    -->nfsd_idmap_init()
        -->net/sunrpc/cache.c: cache_create_net()
        -->net/sunrpc/cache.c: cache_register_net()
            -->create_cache_proc_entries()
                -->fs/proc/generic.c: proc_create_data()
                     create the file's /proc/net/rpc/nfs4.idtoname/{channel,flush,content},
                     the f_ops is {static const struct file_operations cache_file_operations_procfs}


    nfs4 kernel object  Initiated the request, by:
     nfsd_map_name_to_[ug]id()-->do_name_to_id()->idmap_name_to_id()
     nfsd_map_[ug]id_to_name()-->do_id_to_name()->idmap_id_to_name()
        idmap_lookup()
            -->cache_make_upcall()
                -->cd->cache_upcall(cd, h)
                    -->nametoid_upcall()-->sunrpc_cache_pipe_upcall()-->nametoid_request()
                    -->idtoname_upcall()-->sunrpc_cache_pipe_upcall()-->idtoname_request()


In  sunrpc_cache_pipe_upcall()  kmalloc memory to save the imapd_msg info, and should release after  cache_file_operations_procfs.read.
----------------------------------------------------------------------------------------------------------------------------------------

man 7 nfsd

       Each directory representing a cache can hold from 1 to 3 files.  They are:

       flush  When a number of seconds since epoch (1 Jan 1970) is written to this file, all entries in the cache that were last updated before that  file
              become invalidated and will be flushed out.  Writing 1 will flush everything.  This is the only file that will always be present.

       content
              This  file,  if  present,  contains  a  textual  representation of ever entry in the cache, one per line.  If an entry is still in the cache
              (because it is actively being used) but has expired or is otherwise invalid, it will be presented as a comment (with a leading hash  charac‐
              ter).

       channel
              This file, if present, acts a channel for request from the kernel-based nfs server to be passed to a user-space program for handling.

              When  the kernel needs some information which isn't in the cache, it makes a line appear in the channel file giving the key for the informa‐
              tion.  A user-space program should read this, find the answer, and write a line containing the key, an expiry time, and  the  content.   For
              example the kernel might make
                   nfsd 127.0.0.1
              appear in the auth.unix.ip/content file.  The user-space program might then write
                   nfsd 127.0.0.1 1057206953 localhost
              to indicate that 127.0.0.1 should map to localhost, at least for now.

              If  the  program  uses  select(2) or poll(2) to discover if it can read from the channel then it will never see and end-of-file but when all
              requests have been answered, it will block until another request appears.

阅读(1841) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~