SlideShare a Scribd company logo
1 of 44
UNIX V6 セミナー (5)
@magoroku15
2013/6/15
13/6/15 10時49分 1
今日の内容
• UNIXのファイルシステム
第一世代:FS
UNIX V6, UNIX V7, UNIX System V R2-R3
• 名前:固定長14文字
• ブロック管理:配列
第二世代:FFS
4.2BSD
• 名前:可変長、255文字
• ブロック管理:bitmap
• その他:シリンダグループ
第三世代:
• ジャーナルの追加
• ブロック管理:多様化→bitmap、Btreeなど
• 4.2BSDまではOSが扱えるファイルシステムは1種類
– Sun micro systemsのNFSの実装でvnodeを導入
– 複数の種類のファイルシステムを同時に運用可能に
13/6/15 10時49分 2
参照するソースの関係
|
Sixth Edition (V6) -----*
¥ |
Seventh Edition (V7) |
¥ |
¥ 1BSD
32V |
¥ 2BSD---------------*
¥ / |
¥ / |
¥/ |
3BSD |
| |
4.0BSD 2.79BSD
| |
4.1BSD --------------> 2.8BSD
| |
4.1aBSD -----------¥ |
| ¥ |
4.1bBSD ¥ |
| ¥ |
*------ 4.1cBSD --------------> 2.9BSD
/ | |
Eighth Edition | 2.9BSD-Seismo
| | |
+----<--- 4.2BSD 2.9.1BSD
| | |
+----<--- 4.3BSD -------------> 2.10BSD
| | / |
Ninth Edition | / 2.10.1BSD
| 4.3BSD Tahoe-----+ |
| | ¥ |
| | ¥ |
v | 2.11BSD
Tenth Edition | |
| 2.11BSD rev #430
4.3BSD NET/1 |
| v
4.3BSD Reno
|
*---------- 4.3BSD NET/2 -------------------+-------------*
| | | |
386BSD 0.0 | | BSD/386 ALPHA
| | | |
386BSD 0.1 ------------>+ | BSD/386 0.3.[13]
| ¥ | 4.4BSD Alpha |
| 386BSD 1.0 | | BSD/386 0.9.[34]
| | 4.4BSD |
| | / | |
| | 4.4BSD-Encumbered | |
| NetBSD 0.8 | BSD/386 1.0
| | | |
FreeBSD 1.0 NetBSD 0.9 | BSD/386 1.1
| | .----- 4.4BSD Lite |
FreeBSD 1.1
http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/share/misc/bsd-family-tree?rev=HEAD
1992-02-xx
1975-05-xx
1983-08-03
1990-06-29
暗黒時代
和解仕様
13/6/15 10時49分 3
参照するUNIXの特徴
• Sixth Edition (v6)
– Cで書かれた最初のUNIX
– PDP-11依存
• 4.2BSD
– 32bit, 仮想記憶、TCP/IP
– VAX-11依存、後にSun,Sony等がMC680x0に移植
• 4.3BSD Reno
– ハード無依存が進む
– 最後のBSD
– FreeBSD, NetBSD,Mac OSのベース
13/6/15 10時49分 4
ソースのダウンロード元
• V6
– http://www.tom-yam.or.jp/2238/src/
• 4.2BSD
– http://www.tuhs.org/Archive/4BSD/Distributions/
4.2BSD/srcsys.tar.gz
• 4.3BSD (Reno)
– http://www.tuhs.org/Archive/4BSD/Distributions/
4.3BSD-Reno/
13/6/15 10時49分 5
第一世代(FS)課題 1
• ファイル名の最大文字数が短い
– 最大14文字
– SCCS (初期のバージョン管理システム)がサフィッ
クス2文字を必要とするため、実質12文字
• FFSで拡張
– 可変長 最大255文字
13/6/15 10時49分 6
V6のファイルシステム (復習)
13/6/15 10時49分 7
13/6/15 10時49分 8
13/6/15 10時49分 9
13/6/15 10時49分 10
13/6/15 10時49分 11
13/6/15 10時49分 12
13/6/15 10時49分 13
FSの課題と4.2BSD FFSでの改善点
13/6/15 10時49分 14
4.2BSD h/dir.h
35 structdirect {
36 u_long d_ino; /* inode number of entry */
37 u_short d_reclen; /* length of this record */
38 u_short d_namlen; /* length of string in d_name */
39 char d_name[MAXNAMLEN + 1];/* name must be no longer than this */
40 };
ad_ino
32bit
d_reclen d_namlen
16bit 16bit
. o
d_reclen
d_namlen
u t ・・・・・・
13/6/15 10時49分 15
ディレクトリファイルの比較
FS (v6等)
16byte
Blocksz/
16byte
FFS (4.xBSD)
16byte
reclen
reclen
reclen
13/6/15 10時49分 16
4.2bsd/sys/ufs_nami.c#269
404 while (ndp->ni_offset < endsearch) {
267 if (ep->d_ino) {
268 if (ep->d_namlen == u.u_dent.d_namlen &&
269 !bcmp(u.u_dent.d_name, ep->d_name, ep->d_namlen))
270 goto found;
271 }
272 prevoff = u.u_offset;
273 u.u_offset += ep->d_reclen;
274 entryoffsetinblock += ep->d_reclen;
434 ep = (struct direct *)(bp->b_un.b_addr + entryoffsetinblock);
487 }
13/6/15 10時49分 17
第一世代(FS)の課題 2
• ブロック管理が配列
– フラグメンテーションによる経年劣化
– 全てのファイルを削除しても、改善しない
• MKFS直後はFreeBlockはブロック昇順
• ファイルの削除でFreeBlockはランダム化
• 全てのファイルを削除してもFreeBlockはランダムのまま
– 運用マニュアルに以下の注意が記載
• バックアップのために定期的にdumpコマンドを実行
• 一定期間を経るとフラグメンテーションにより性能の劣化が
著しくなるので、mkfsで初期化して、restoreコマンドを実行
13/6/15 10時49分 18
フラグメンテーション
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29Free
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29Free
Create File A with 10 blocks
26 27 28 29Free
Create File B and C with 8 blocks for each files
1 2 3 4 5 6 7 8 9 10
11 13 15 17 19 21 23 25
12 14 16 18 20 22 24 26
A
B
C
12 14 16 18 20 22 24 26 11 13 15 17 19 21 23 25 1 2 3 4 5 6 7 8 9 10 26 27 28 29Free
Remove file A, B, C
Create File A with 10 blocks
12 14 16 18 20 22 24 26 11 13A
ブロック位置の差は合計9
ブロック位置の差は合計31
13/6/15 10時49分 19
媒体配置の改善 その1
• FreeBlockの管理を配列から、ビットマップへ
変更
• write(2)を辿ってみる
13/6/15 10時49分 20
4.2bsd/sys/sys_generic.c
66 write()
67 {
68 register struct a {
69 int fdes;
70 char *cbuf;
71 unsigned count;
72 } *uap = (struct a *)u.u_ap;
73 struct uio auio;
74 struct iovec aiov;
75
76 auio.uio_iov = &aiov;
77 auio.uio_iovcnt = 1;
78 aiov.iov_base = uap->cbuf;
79 aiov.iov_len = uap->count;
80 rwuio(&auio, UIO_WRITE);
81 }
13/6/15 10時49分 21
4.2bsd/sys/sys_generic.c
106 rwuio(uio, rw)
107 register struct uio *uio;
108 enum uio_rw rw;
109 {
110 struct a {
111 int fdes;
112 };
113 register struct file *fp;
114 register struct iovec *iov;
115 int i, count;
116
117 GETF(fp, ((struct a *)u.u_ap)->fdes);
122 uio->uio_resid = 0;
123 uio->uio_segflg = UIO_USERSPACE;
124 iov = uio->uio_iov;
125 for (i = 0; i < uio->uio_iovcnt; i++) {
130 uio->uio_resid += iov->iov_len;
135 iov++;
136 }
137 count = uio->uio_resid;
138 uio->uio_offset = fp->f_offset;
147 u.u_error = (*fp->f_ops->fo_rw)(fp, rw, uio);
148 u.u_r.r_val1 = count - uio->uio_resid;
149 fp->f_offset += u.u_r.r_val1;
150 }
13/6/15 10時49分 22
4.2bsd/h/file.h
10 /*
11 * Descriptor table entry.
12 * One for each kernel object.
13 */
14 structfile {
15 int f_flag; /* see below */
16 short f_type; /* descriptor type */
17 short f_count; /* reference count */
18 short f_msgcount; /* references from message queue */
19 struct fileops {
20 int (*fo_rw)();
21 int (*fo_ioctl)();
22 int (*fo_select)();
23 int (*fo_close)();
24 } *f_ops;
25 caddr_t f_data; /* inode */
26 off_t f_offset;
27 };
28
13/6/15 10時49分 23
fp->fopsの値
13/6/15 10時49分 24
4.2bsd/sys/sys_socket.c
25 int soo_rw(), soo_ioctl(), soo_select(), soo_close();
26 struct fileops socketops =
27 { soo_rw, soo_ioctl, soo_select, soo_close };
28
29 soo_rw(fp, rw, uio)
30 struct file *fp;
31 enum uio_rw rw;
32 struct uio *uio;
33 {
34 int soreceive(), sosend();
35
36 return (
37 (*(rw==UIO_READ?soreceive:sosend))
38 ((struct socket *)fp->f_data, 0, uio, 0, 0));
39 }
13/6/15 10時49分 25
4.2bsd/sys/sys_inode.c
27 int ino_rw(), ino_ioctl(), ino_select(), ino_close();
28 struct fileops inodeops =
29 { ino_rw, ino_ioctl, ino_select, ino_close };
30
31 ino_rw(fp, rw, uio)
32 struct file *fp;
33 enum uio_rw rw;
34 struct uio *uio;
35 {
36 register struct inode *ip = (struct inode *)fp->f_data;
37 int error;
38
39 if ((ip->i_mode&IFMT) == IFREG) {
40 ILOCK(ip);
41 if (fp->f_flag&FAPPEND && rw == UIO_WRITE)
42 uio->uio_offset = fp->f_offset = ip->i_size;
43 error = rwip(ip, uio, rw);
44 IUNLOCK(ip);
45 } else
46 error = rwip(ip, uio, rw);
47 return (error);
48 }
49
13/6/15 10時49分 26
4.2bsd/sys/sys_inode.c
78 rwip(ip, uio, rw)
79 register struct inode *ip;
80 register struct uio *uio;
81 enum uio_rw rw;
82 {
126 do {
127 lbn = uio->uio_offset / bsize;
128 on = uio->uio_offset % bsize;
129 n = MIN((unsigned)(bsize - on), uio->uio_resid);
130 if (type != IFBLK) {
131 if (rw == UIO_READ) {
132 int diff = ip->i_size - uio->uio_offset;
133 if (diff <= 0)
134 return (0);
135 if (diff < n)
136 n = diff;
137 }
138 bn = fsbtodb(fs,
139 bmap(ip, lbn, rw == UIO_WRITE ? B_WRITE: B_READ, (int)(on+n)));
140 if (u.u_error || rw == UIO_WRITE && (long)bn<0)
141 return (u.u_error);
142 if (rw == UIO_WRITE && uio->uio_offset + n > ip->i_size &&
143 (type == IFDIR || type == IFREG || type == IFLNK))
144 ip->i_size = uio->uio_offset + n;
145 size = blksize(fs, ip, lbn);
146 } else {
147 bn = lbn * (BLKDEV_IOSIZE/DEV_BSIZE);
148 rablock = bn + (BLKDEV_IOSIZE/DEV_BSIZE);
149 rasize = size = bsize;
150 }
13/6/15 10時49分 27
4.2bsd/sys/ufs_bmap.c
28 bmap(ip, bn, rwflg, size)
29 register struct inode *ip;
30 daddr_t bn;
31 int rwflg;
32 int size; /* supplied only when rwflg == B_WRITE */
33 {
34 register int i;
35 int osize, nsize;
36 struct buf *bp, *nbp;
37 struct fs *fs;
38 int j, sh;
39 daddr_t nb, lbn, *bap, pref, blkpref();
40
45 fs = ip->i_fs;
46 rablock = 0;
47 rasize = 0; /* conservative */
48
49 /*
50 * If the next write will extend the file into a new block,
51 * and the file is currently composed of a fragment
52 * this fragment has to be extended to be a full block.
53 */
54 nb = lblkno(fs, ip->i_size);
55 if (rwflg == B_WRITE && nb < NDADDR && nb < bn) {
56 osize = blksize(fs, ip, nb);
57 if (osize < fs->fs_bsize && osize > 0) {
58 bp = realloccg(ip, ip->i_db[nb],
59 blkpref(ip, nb, (int)nb, &ip->i_db[0]),
60 osize, (int)fs->fs_bsize);
61 if (bp == NULL)
62 return ((daddr_t)-1);
63 ip->i_size = (nb + 1) * fs->fs_bsize;
64 ip->i_db[nb] = dbtofsb(fs, bp->b_blkno);
65 ip->i_flag |= IUPD|ICHG;
66 bdwrite(bp);
67 }
68 }
13/6/15 10時49分 28
4.2bsd/sys/ufs_alloc.c
107 struct buf *
108 realloccg(ip, bprev, bpref, osize, nsize)
109 register struct inode *ip;
110 daddr_t bprev, bpref;
111 int osize, nsize;
112 {
139 cg = dtog(fs, bprev);
140 bno = fragextend(ip, cg, (long)bprev, osize, nsize);
141 if (bno != 0) {
142 do {
143 bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
144 if (bp->b_flags & B_ERROR) {
145 brelse(bp);
146 return (NULL);
147 }
148 } while (brealloc(bp, nsize) == 0);
149 bp->b_flags |= B_DONE;
150 bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
151 ip->i_blocks += btodb(nsize - osize);
152 ip->i_flag |= IUPD|ICHG;
153 return (bp);
154 }
155 if (bpref >= fs->fs_size)
156 bpref = 0;
13/6/15 10時49分 29
4.2bsd/sys/ufs_alloc.c
481 fragextend(ip, cg, bprev, osize, nsize)
482 struct inode *ip;
483 int cg;
484 long bprev;
485 int osize, nsize;
486 {
510 bno = dtogd(fs, bprev);
511 for (i = numfrags(fs, osize); i < frags; i++)
512 if (isclr(cgp->cg_free, bno + i)) {
513 brelse(bp);
514 return (NULL);
515 }
516 /*
517 * the current fragment can be extended
518 * deduct the count on fragment being extended into
519 * increase the count on the remaining fragment (if any)
520 * allocate the extended piece
521 */
522 for (i = frags; i < fs->fs_frag - bbase; i++)
523 if (isclr(cgp->cg_free, bno + i))
524 break;
525 cgp->cg_frsum[i - numfrags(fs, osize)]--;
526 if (i != frags)
527 cgp->cg_frsum[i - frags]++;
528 for (i = numfrags(fs, osize); i < frags; i++) {
529 clrbit(cgp->cg_free, bno + i);
530 cgp->cg_cs.cs_nffree--;
531 fs->fs_cstotal.cs_nffree--;
532 fs->fs_cs(fs, cg).cs_nffree--;
533 }
534 fs->fs_fmod++;
535 bdwrite(bp);
536 return (bprev);
537 }
13/6/15 10時49分 30
4.2bsd/h/param.h
160 /*
161 * bit map related macros
162 */
163 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
164 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
165 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
166 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
13/6/15 10時49分 31
4.2bsd/h/fs.h
/*
230 * Cylinder group block for a file system.
231 */
232 #define CG_MAGIC 0x090255
233 struct cg {
234 struct cg *cg_link; /* linked list of cyl groups */
235 struct cg *cg_rlink; /* used for incore cyl groups */
236 time_t cg_time; /* time last written */
237 long cg_cgx; /* we are the cgx'th cylinder group */
238 short cg_ncyl; /* number of cyl's this cg */
239 short cg_niblk; /* number of inode blocks this cg */
240 long cg_ndblk; /* number of data blocks this cg */
241 struct csum cg_cs; /* cylinder summary information */
242 long cg_rotor; /* position of last used block */
243 long cg_frotor; /* position of last used frag */
244 long cg_irotor; /* position of last used inode */
245 long cg_frsum[MAXFRAG]; /* counts of available frags */
246 long cg_btot[MAXCPG]; /* block totals per cylinder */
247 short cg_b[MAXCPG][NRPOS]; /* positions of free blocks */
248 char cg_iused[MAXIPG/NBBY]; /* used inode map */
249 long cg_magic; /* magic number */
250 u_char cg_free[1]; /* free block map */
251 /* actually longer */
252 };
13/6/15 10時49分 32
4.2bsd/h/fs.h
129 /*
130 * Super block for a file system.
131 */
132 #define FS_MAGIC 0x011954
133 struct fs
134 {
135 struct fs *fs_link; /* linked list of file systems */
136 struct fs *fs_rlink; /* used for incore super blocks */
137 daddr_t fs_sblkno; /* addr of super-block in filesys */
138 daddr_t fs_cblkno; /* offset of cyl-block in filesys */
139 daddr_t fs_iblkno; /* offset of inode-blocks in filesys */
140 daddr_t fs_dblkno; /* offset of first data after cg */
141 long fs_cgoffset; /* cylinder group offset in cylinder */
142 long fs_cgmask; /* used to calc mod fs_ntrak */
143 time_t fs_time; /* last time written */
144 long fs_size; /* number of blocks in fs */
145 long fs_dsize; /* number of data blocks in fs */
146 long fs_ncg; /* number of cylinder groups */
147 long fs_bsize; /* size of basic blocks in fs */
148 long fs_fsize; /* size of frag blocks in fs */
149 long fs_frag; /* number of frags in a block in fs */
150 /* these are configuration parameters */
154 /* these fields can be computed from the others */
159 /* these are configuration parameters */
162 /* these fields can be computed from the others */
173 /* sizes determined by number of cylinder groups and their sizes */
177 /* these fields should be derived from the hardware */
181 /* this comes from the disk driver partitioning */
183 /* these fields can be computed from the others */
187 /* this data must be re-computed after crashes */
189 /* these fields are cleared at mount time */
195 /* these fields retain the current block allocation info */
202 /* actually longer */
203 };
13/6/15 10時49分 33
媒体配置の改善 その2
• Cylinder Groupによる、シーク時間の改善
– Diskの大容量化、CPUの高速化でシーク時間の
影響が増大
– 1つのファイルには可能な限り近傍のブロックを
集めたい
→Cylinder Group
13/6/15 10時49分 34
Data
Inode
Cylinder group
FS FFS
data blocks
Inode blocks
Struct inode[]
Super block
Boot block
Super block
Boot block
Cylinder group
Data
Inode
Cylinder group
FreeListは
bitmap管理
13/6/15 10時49分 35
h/inode.h
14 struct inode {
15 struct inode *i_chain[2]; /* must be first */
16 u_short i_flag;
17 u_short i_count; /* reference count */
18 dev_t i_dev; /* device where inode resides */
19 u_short i_shlockc; /* count of shared locks on inode */
20 u_short i_exlockc; /* count of exclusive locks on inode */
21 ino_t i_number; /* i number, 1-to-1 with device address */
22 struct fs *i_fs; /* file sys associated with this inode */
23 struct dquot *i_dquot; /* quota structure controlling this file */
24 union {
25 daddr_t if_lastr; /* last read (read-ahead) */
26 struct socket *is_socket;
27 struct {
28 struct inode *if_freef; /* free list forward */
29 struct inode **if_freeb; /* free list back */
30 } i_fr;
31 } i_un;
32 struct icommon
33 {
34 u_short ic_mode; /* 0: mode and type of file */
35 short ic_nlink; /* 2: number of links to file */
36 short ic_uid; /* 4: owner's user id */
37 short ic_gid; /* 6: owner's group id */
38 quad ic_size; /* 8: number of bytes in file */
39 time_t ic_atime; /* 16: time last accessed */
40 long ic_atspare;
41 time_t ic_mtime; /* 24: time last modified */
42 long ic_mtspare;
43 time_t ic_ctime; /* 32: last time inode changed */
44 long ic_ctspare;
45 daddr_t ic_db[NDADDR]; /* 40: disk block addresses */
46 daddr_t ic_ib[NIADDR]; /* 88: indirect blocks */
47 long ic_flags; /* 100: status, currently unused */
48 long ic_blocks; /* 104: blocks actually held */
49 long ic_spare[5]; /* 108: reserved, currently unused */
50 } i_ic;
51 };
52
53 struct dinode {
54 union {
55 struct icommon di_icom;
56 char di_size[128];
57 } di_un;
58 };
inode
icommon
struct dinode =
struct icommon
13/6/15 10時49分 36
Disk inode FSとFFSの違い
FSのdisk inode
5605 struct inode
5606 {
5607 int i_mode;
5608 char i_nlink;
5609 char i_uid;
5610 char i_gid;
5611 char i_size0;
5612 char *i_size1;
5613 int i_addr[8];
5614 int i_atime[2];
5615 int i_mtime[2];
5616 };
FFSのdisk inode
32 struct icommon
33 {
34 u_short ic_mode; /* 0: mode and type of file */
35 short ic_nlink; /* 2: number of links to file */
36 short ic_uid; /* 4: owner's user id */
37 short ic_gid; /* 6: owner's group id */
38 quad ic_size; /* 8: number of bytes in file */
39 time_t ic_atime; /* 16: time last accessed */
40 long ic_atspare;
41 time_t ic_mtime; /* 24: time last modified */
42 long ic_mtspare;
43 time_t ic_ctime; /* 32: last time inode changed */
44 long ic_ctspare;
45 daddr_t ic_db[NDADDR]; /* 40: disk block addresses */
46 daddr_t ic_ib[NIADDR]; /* 88: indirect blocks */
47 long ic_flags; /* 100: status, currently unused */
48 long ic_blocks; /* 104: blocks actually held */
49 long ic_spare[5]; /* 108: reserved, currently unused */
50 } i_ic;
13/6/15 10時49分 37
4.3BSD-RENOに見るVNODE
13/6/15 10時49分 38
FS,FFSの上位構造
fd = open()
プロセス
proc
user
15個
file[NFILE]
u_ofile[NOFILE]
inode[NINODE]
i_number
i_number
キャッシュバッファ
媒体
手続き
namei
rwip
13/6/15 10時49分 39
異なるFSを利用するには?
• FS毎に異なる構造・手続き
– inodeの管理
– 名前の管理
– ブロックの管理
• VNODEの登場
– Incore InodeからFS依存部を取り除き、Inodeの操
作手続きを内包
13/6/15 10時49分 40
VNODEの役割
fd = open()
プロセス
proc
user
15個
file
u_ofile[NOFILE]
vnode
i_number
i_number
キャッシュバッファ
FSTYPE
手続き
VOP_LOOKUP
VOP_READ
VOP_WRITE
FSTYPE
13/6/15 10時49分 41
Inode操作とvnode操作の違い
4.2bsd/sys/sys_inode.c
50 rdwri(rw, ip, base, len, offset, segflg, aresid)
51 struct inode *ip;
52 caddr_t base;
53 int len, segflg;
54 off_t offset;
55 int *aresid;
56 enum uio_rw rw;
57 {
58 struct uio auio;
59 struct iovec aiov;
60 int error;
61
62 auio.uio_iov = &aiov;
63 auio.uio_iovcnt = 1;
64 aiov.iov_base = base;
65 aiov.iov_len = len;
66 auio.uio_resid = len;
67 auio.uio_offset = offset;
68 auio.uio_segflg = segflg;
69 error = rwip(ip, &auio, rw);
70 if (aresid)
71 *aresid = auio.uio_resid;
72 else
73 if (auio.uio_resid)
74 error = EIO;
75 return (error);
76 }
4.3bsd_reno/kern/vfs_vnops.c
157 vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid)
158 enum uio_rw rw;
159 struct vnode *vp;
160 caddr_t base;
161 int len;
162 off_t offset;
163 enum uio_seg segflg;
164 int ioflg;
165 struct ucred *cred;
166 int *aresid;
167 {
168 struct uio auio;
169 struct iovec aiov;
170 int error;
171
172 if ((ioflg & IO_NODELOCKED) == 0)
173 VOP_LOCK(vp);
174 auio.uio_iov = &aiov;
175 auio.uio_iovcnt= 1;
176 aiov.iov_base = base;
177 aiov.iov_len = len;
178 auio.uio_resid = len;
179 auio.uio_offset = offset;
180 auio.uio_segflg = segflg;
181 auio.uio_rw = rw;
182 if (rw == UIO_READ)
183 error = VOP_READ(vp, &auio, ioflg, cred);
184 else
185 error = VOP_WRITE(vp,&auio, ioflg, cred);
186 if (aresid)
187 *aresid = auio.uio_resid;
188 else
189 if (auio.uio_resid && error == 0)
190 error = EIO;
191 if ((ioflg & IO_NODELOCKED) == 0)
192 VOP_UNLOCK(vp);
193 return (error);
194 }
13/6/15 10時49分 42
VNODEの背景
• NFSの登場
– 4.3BSD Renoは公開プロトコルを利用した独自実
装を取り込んだ
• read(2)->read()->vn_rdwr()->VOP_READ(vp)
– vpがNFSのvnodeならnfs_read()が
– vpがUSFのvnodeならufs_read()が
呼び出される
13/6/15 10時49分 43
以上
13/6/15 10時49分 44

More Related Content

What's hot

DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterAndrey Kudryavtsev
 
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club UkraineKubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club UkraineElixir Club
 
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki LinnakangasPG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangaspgdayrussia
 
This is not your father's monitoring.
This is not your father's monitoring.This is not your father's monitoring.
This is not your father's monitoring.Mathias Herberts
 
Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Mathias Herberts
 
Qt native built for raspberry zero
Qt native built for  raspberry zeroQt native built for  raspberry zero
Qt native built for raspberry zeroSoheilSabzevari2
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Hua Chu
 
101 4.3 control mounting and unmounting of filesystems v2
101 4.3 control mounting and unmounting of filesystems v2101 4.3 control mounting and unmounting of filesystems v2
101 4.3 control mounting and unmounting of filesystems v2Acácio Oliveira
 
[ETHCon Korea 2019] Shin mansun 신만선
[ETHCon Korea 2019] Shin mansun 신만선[ETHCon Korea 2019] Shin mansun 신만선
[ETHCon Korea 2019] Shin mansun 신만선ethconkr
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4Benux Wei
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksMarian Marinov
 
Threads Advance in System Administration with Linux
Threads Advance in System Administration with LinuxThreads Advance in System Administration with Linux
Threads Advance in System Administration with LinuxSoumen Santra
 
4.3 control mounting and unmounting of filesystems v2
4.3 control mounting and unmounting of filesystems v24.3 control mounting and unmounting of filesystems v2
4.3 control mounting and unmounting of filesystems v2Acácio Oliveira
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby SystemsEngine Yard
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging RubyAman Gupta
 
On cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwordsOn cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwordspcmanus
 
2013 0928 programming by cuda
2013 0928 programming by cuda2013 0928 programming by cuda
2013 0928 programming by cuda小明 王
 

What's hot (20)

R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club UkraineKubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
Kubernetes + Docker + Elixir - Alexei Sholik, Andrew Dryga | Elixir Club Ukraine
 
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki LinnakangasPG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
 
This is not your father's monitoring.
This is not your father's monitoring.This is not your father's monitoring.
This is not your father's monitoring.
 
Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108
 
Qt native built for raspberry zero
Qt native built for  raspberry zeroQt native built for  raspberry zero
Qt native built for raspberry zero
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python
 
101 4.3 control mounting and unmounting of filesystems v2
101 4.3 control mounting and unmounting of filesystems v2101 4.3 control mounting and unmounting of filesystems v2
101 4.3 control mounting and unmounting of filesystems v2
 
[ETHCon Korea 2019] Shin mansun 신만선
[ETHCon Korea 2019] Shin mansun 신만선[ETHCon Korea 2019] Shin mansun 신만선
[ETHCon Korea 2019] Shin mansun 신만선
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networks
 
Zookeper
ZookeperZookeper
Zookeper
 
PaaS祭り - pagoda box
PaaS祭り - pagoda boxPaaS祭り - pagoda box
PaaS祭り - pagoda box
 
Threads Advance in System Administration with Linux
Threads Advance in System Administration with LinuxThreads Advance in System Administration with Linux
Threads Advance in System Administration with Linux
 
4.3 control mounting and unmounting of filesystems v2
4.3 control mounting and unmounting of filesystems v24.3 control mounting and unmounting of filesystems v2
4.3 control mounting and unmounting of filesystems v2
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
 
On cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwordsOn cassandra's evolution @ Berlin buzzwords
On cassandra's evolution @ Berlin buzzwords
 
2013 0928 programming by cuda
2013 0928 programming by cuda2013 0928 programming by cuda
2013 0928 programming by cuda
 

Viewers also liked

Viewers also liked (10)

Oscar compiler for power reduction
Oscar compiler for power reduction Oscar compiler for power reduction
Oscar compiler for power reduction
 
波形で見るBig.little
波形で見るBig.little波形で見るBig.little
波形で見るBig.little
 
V6 unix in okinawa
V6 unix in okinawaV6 unix in okinawa
V6 unix in okinawa
 
Android binder-ipc
Android binder-ipcAndroid binder-ipc
Android binder-ipc
 
自動並列化コンパイラをAndroidに適用してみた
自動並列化コンパイラをAndroidに適用してみた自動並列化コンパイラをAndroidに適用してみた
自動並列化コンパイラをAndroidに適用してみた
 
Deep learning入門
Deep learning入門Deep learning入門
Deep learning入門
 
Android ipm 20110409
Android ipm 20110409Android ipm 20110409
Android ipm 20110409
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 

Similar to Unix v6 セミナー vol. 5

various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)CODE BLUE
 
Introduction to Kernel Programming
Introduction to Kernel ProgrammingIntroduction to Kernel Programming
Introduction to Kernel ProgrammingAhmed Mekkawy
 
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法MITSUNARI Shigeo
 
Return Oriented Programming, an introduction
Return Oriented Programming, an introductionReturn Oriented Programming, an introduction
Return Oriented Programming, an introductionPatricia Aas
 
Gazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmGazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmMasahiro Nagano
 
High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)
High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)
High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)Naoto MATSUMOTO
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321Teddy Hsiung
 
Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Hajime Tazaki
 
OSPF (open shortest path first) part iii
OSPF (open shortest path first) part  iiiOSPF (open shortest path first) part  iii
OSPF (open shortest path first) part iiiNetwax Lab
 
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
[2007 CodeEngn Conference 01] seaofglass - Linux Virus AnalysisGangSeok Lee
 
Show innodb status
Show innodb statusShow innodb status
Show innodb statusjustlooks
 
Alexander Reelsen - Seccomp for Developers
Alexander Reelsen - Seccomp for DevelopersAlexander Reelsen - Seccomp for Developers
Alexander Reelsen - Seccomp for DevelopersDevDay Dresden
 
OSPF (open shortest path first) part ii
OSPF (open shortest path first) part  iiOSPF (open shortest path first) part  ii
OSPF (open shortest path first) part iiNetwax Lab
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdfmaheshkumar12354
 
How debuggers-work
How debuggers-workHow debuggers-work
How debuggers-work辉 王
 

Similar to Unix v6 セミナー vol. 5 (20)

Usp
UspUsp
Usp
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
 
Introduction to Kernel Programming
Introduction to Kernel ProgrammingIntroduction to Kernel Programming
Introduction to Kernel Programming
 
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
 
Return Oriented Programming, an introduction
Return Oriented Programming, an introductionReturn Oriented Programming, an introduction
Return Oriented Programming, an introduction
 
20141106 asfws unicode_hacks
20141106 asfws unicode_hacks20141106 asfws unicode_hacks
20141106 asfws unicode_hacks
 
Gazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmGazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapm
 
Hacking the swisscom modem
Hacking the swisscom modemHacking the swisscom modem
Hacking the swisscom modem
 
High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)
High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)
High Availability Server Clustering without ILB(Internal Load Balancer) (MEMO)
 
Sysprog 11
Sysprog 11Sysprog 11
Sysprog 11
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
 
Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01
 
OSPF (open shortest path first) part iii
OSPF (open shortest path first) part  iiiOSPF (open shortest path first) part  iii
OSPF (open shortest path first) part iii
 
Containers for sysadmins
Containers for sysadminsContainers for sysadmins
Containers for sysadmins
 
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
[2007 CodeEngn Conference 01] seaofglass - Linux Virus Analysis
 
Show innodb status
Show innodb statusShow innodb status
Show innodb status
 
Alexander Reelsen - Seccomp for Developers
Alexander Reelsen - Seccomp for DevelopersAlexander Reelsen - Seccomp for Developers
Alexander Reelsen - Seccomp for Developers
 
OSPF (open shortest path first) part ii
OSPF (open shortest path first) part  iiOSPF (open shortest path first) part  ii
OSPF (open shortest path first) part ii
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
 
How debuggers-work
How debuggers-workHow debuggers-work
How debuggers-work
 

More from magoroku Yamamoto

More from magoroku Yamamoto (20)

仮想記憶入門 BSD-4.3を例題に
仮想記憶入門 BSD-4.3を例題に仮想記憶入門 BSD-4.3を例題に
仮想記憶入門 BSD-4.3を例題に
 
V6 unix vol.2 in okinawa
V6 unix vol.2 in okinawaV6 unix vol.2 in okinawa
V6 unix vol.2 in okinawa
 
Adk2012
Adk2012Adk2012
Adk2012
 
ぐだ生システム#2
ぐだ生システム#2ぐだ生システム#2
ぐだ生システム#2
 
ぐだ生って何
ぐだ生って何ぐだ生って何
ぐだ生って何
 
Android builders summit slide tour
Android builders summit slide tourAndroid builders summit slide tour
Android builders summit slide tour
 
第4回名古屋Android勉強会資料
第4回名古屋Android勉強会資料第4回名古屋Android勉強会資料
第4回名古屋Android勉強会資料
 
Poorman’s adk トレーナ
Poorman’s adk トレーナPoorman’s adk トレーナ
Poorman’s adk トレーナ
 
20分でわかった事にするパワーマネジメント
20分でわかった事にするパワーマネジメント20分でわかった事にするパワーマネジメント
20分でわかった事にするパワーマネジメント
 
Poormans sdk
Poormans sdkPoormans sdk
Poormans sdk
 
Ngk2011 b
Ngk2011 bNgk2011 b
Ngk2011 b
 
オレオレ家電
オレオレ家電オレオレ家電
オレオレ家電
 
V6read#4
V6read#4V6read#4
V6read#4
 
V6read#3
V6read#3V6read#3
V6read#3
 
Unixファイルシステムの歴史
Unixファイルシステムの歴史Unixファイルシステムの歴史
Unixファイルシステムの歴史
 
Pdp11 on-fpga
Pdp11 on-fpgaPdp11 on-fpga
Pdp11 on-fpga
 
V6read#2
V6read#2V6read#2
V6read#2
 
Androidの入力システム
Androidの入力システムAndroidの入力システム
Androidの入力システム
 
ぐだ生システム再構成4
ぐだ生システム再構成4ぐだ生システム再構成4
ぐだ生システム再構成4
 
20分で理解する仮想記憶
20分で理解する仮想記憶20分で理解する仮想記憶
20分で理解する仮想記憶
 

Recently uploaded

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Recently uploaded (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 

Unix v6 セミナー vol. 5

  • 1. UNIX V6 セミナー (5) @magoroku15 2013/6/15 13/6/15 10時49分 1
  • 2. 今日の内容 • UNIXのファイルシステム 第一世代:FS UNIX V6, UNIX V7, UNIX System V R2-R3 • 名前:固定長14文字 • ブロック管理:配列 第二世代:FFS 4.2BSD • 名前:可変長、255文字 • ブロック管理:bitmap • その他:シリンダグループ 第三世代: • ジャーナルの追加 • ブロック管理:多様化→bitmap、Btreeなど • 4.2BSDまではOSが扱えるファイルシステムは1種類 – Sun micro systemsのNFSの実装でvnodeを導入 – 複数の種類のファイルシステムを同時に運用可能に 13/6/15 10時49分 2
  • 3. 参照するソースの関係 | Sixth Edition (V6) -----* ¥ | Seventh Edition (V7) | ¥ | ¥ 1BSD 32V | ¥ 2BSD---------------* ¥ / | ¥ / | ¥/ | 3BSD | | | 4.0BSD 2.79BSD | | 4.1BSD --------------> 2.8BSD | | 4.1aBSD -----------¥ | | ¥ | 4.1bBSD ¥ | | ¥ | *------ 4.1cBSD --------------> 2.9BSD / | | Eighth Edition | 2.9BSD-Seismo | | | +----<--- 4.2BSD 2.9.1BSD | | | +----<--- 4.3BSD -------------> 2.10BSD | | / | Ninth Edition | / 2.10.1BSD | 4.3BSD Tahoe-----+ | | | ¥ | | | ¥ | v | 2.11BSD Tenth Edition | | | 2.11BSD rev #430 4.3BSD NET/1 | | v 4.3BSD Reno | *---------- 4.3BSD NET/2 -------------------+-------------* | | | | 386BSD 0.0 | | BSD/386 ALPHA | | | | 386BSD 0.1 ------------>+ | BSD/386 0.3.[13] | ¥ | 4.4BSD Alpha | | 386BSD 1.0 | | BSD/386 0.9.[34] | | 4.4BSD | | | / | | | | 4.4BSD-Encumbered | | | NetBSD 0.8 | BSD/386 1.0 | | | | FreeBSD 1.0 NetBSD 0.9 | BSD/386 1.1 | | .----- 4.4BSD Lite | FreeBSD 1.1 http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/share/misc/bsd-family-tree?rev=HEAD 1992-02-xx 1975-05-xx 1983-08-03 1990-06-29 暗黒時代 和解仕様 13/6/15 10時49分 3
  • 4. 参照するUNIXの特徴 • Sixth Edition (v6) – Cで書かれた最初のUNIX – PDP-11依存 • 4.2BSD – 32bit, 仮想記憶、TCP/IP – VAX-11依存、後にSun,Sony等がMC680x0に移植 • 4.3BSD Reno – ハード無依存が進む – 最後のBSD – FreeBSD, NetBSD,Mac OSのベース 13/6/15 10時49分 4
  • 5. ソースのダウンロード元 • V6 – http://www.tom-yam.or.jp/2238/src/ • 4.2BSD – http://www.tuhs.org/Archive/4BSD/Distributions/ 4.2BSD/srcsys.tar.gz • 4.3BSD (Reno) – http://www.tuhs.org/Archive/4BSD/Distributions/ 4.3BSD-Reno/ 13/6/15 10時49分 5
  • 6. 第一世代(FS)課題 1 • ファイル名の最大文字数が短い – 最大14文字 – SCCS (初期のバージョン管理システム)がサフィッ クス2文字を必要とするため、実質12文字 • FFSで拡張 – 可変長 最大255文字 13/6/15 10時49分 6
  • 15. 4.2BSD h/dir.h 35 structdirect { 36 u_long d_ino; /* inode number of entry */ 37 u_short d_reclen; /* length of this record */ 38 u_short d_namlen; /* length of string in d_name */ 39 char d_name[MAXNAMLEN + 1];/* name must be no longer than this */ 40 }; ad_ino 32bit d_reclen d_namlen 16bit 16bit . o d_reclen d_namlen u t ・・・・・・ 13/6/15 10時49分 15
  • 17. 4.2bsd/sys/ufs_nami.c#269 404 while (ndp->ni_offset < endsearch) { 267 if (ep->d_ino) { 268 if (ep->d_namlen == u.u_dent.d_namlen && 269 !bcmp(u.u_dent.d_name, ep->d_name, ep->d_namlen)) 270 goto found; 271 } 272 prevoff = u.u_offset; 273 u.u_offset += ep->d_reclen; 274 entryoffsetinblock += ep->d_reclen; 434 ep = (struct direct *)(bp->b_un.b_addr + entryoffsetinblock); 487 } 13/6/15 10時49分 17
  • 18. 第一世代(FS)の課題 2 • ブロック管理が配列 – フラグメンテーションによる経年劣化 – 全てのファイルを削除しても、改善しない • MKFS直後はFreeBlockはブロック昇順 • ファイルの削除でFreeBlockはランダム化 • 全てのファイルを削除してもFreeBlockはランダムのまま – 運用マニュアルに以下の注意が記載 • バックアップのために定期的にdumpコマンドを実行 • 一定期間を経るとフラグメンテーションにより性能の劣化が 著しくなるので、mkfsで初期化して、restoreコマンドを実行 13/6/15 10時49分 18
  • 19. フラグメンテーション 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29Free 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29Free Create File A with 10 blocks 26 27 28 29Free Create File B and C with 8 blocks for each files 1 2 3 4 5 6 7 8 9 10 11 13 15 17 19 21 23 25 12 14 16 18 20 22 24 26 A B C 12 14 16 18 20 22 24 26 11 13 15 17 19 21 23 25 1 2 3 4 5 6 7 8 9 10 26 27 28 29Free Remove file A, B, C Create File A with 10 blocks 12 14 16 18 20 22 24 26 11 13A ブロック位置の差は合計9 ブロック位置の差は合計31 13/6/15 10時49分 19
  • 21. 4.2bsd/sys/sys_generic.c 66 write() 67 { 68 register struct a { 69 int fdes; 70 char *cbuf; 71 unsigned count; 72 } *uap = (struct a *)u.u_ap; 73 struct uio auio; 74 struct iovec aiov; 75 76 auio.uio_iov = &aiov; 77 auio.uio_iovcnt = 1; 78 aiov.iov_base = uap->cbuf; 79 aiov.iov_len = uap->count; 80 rwuio(&auio, UIO_WRITE); 81 } 13/6/15 10時49分 21
  • 22. 4.2bsd/sys/sys_generic.c 106 rwuio(uio, rw) 107 register struct uio *uio; 108 enum uio_rw rw; 109 { 110 struct a { 111 int fdes; 112 }; 113 register struct file *fp; 114 register struct iovec *iov; 115 int i, count; 116 117 GETF(fp, ((struct a *)u.u_ap)->fdes); 122 uio->uio_resid = 0; 123 uio->uio_segflg = UIO_USERSPACE; 124 iov = uio->uio_iov; 125 for (i = 0; i < uio->uio_iovcnt; i++) { 130 uio->uio_resid += iov->iov_len; 135 iov++; 136 } 137 count = uio->uio_resid; 138 uio->uio_offset = fp->f_offset; 147 u.u_error = (*fp->f_ops->fo_rw)(fp, rw, uio); 148 u.u_r.r_val1 = count - uio->uio_resid; 149 fp->f_offset += u.u_r.r_val1; 150 } 13/6/15 10時49分 22
  • 23. 4.2bsd/h/file.h 10 /* 11 * Descriptor table entry. 12 * One for each kernel object. 13 */ 14 structfile { 15 int f_flag; /* see below */ 16 short f_type; /* descriptor type */ 17 short f_count; /* reference count */ 18 short f_msgcount; /* references from message queue */ 19 struct fileops { 20 int (*fo_rw)(); 21 int (*fo_ioctl)(); 22 int (*fo_select)(); 23 int (*fo_close)(); 24 } *f_ops; 25 caddr_t f_data; /* inode */ 26 off_t f_offset; 27 }; 28 13/6/15 10時49分 23
  • 25. 4.2bsd/sys/sys_socket.c 25 int soo_rw(), soo_ioctl(), soo_select(), soo_close(); 26 struct fileops socketops = 27 { soo_rw, soo_ioctl, soo_select, soo_close }; 28 29 soo_rw(fp, rw, uio) 30 struct file *fp; 31 enum uio_rw rw; 32 struct uio *uio; 33 { 34 int soreceive(), sosend(); 35 36 return ( 37 (*(rw==UIO_READ?soreceive:sosend)) 38 ((struct socket *)fp->f_data, 0, uio, 0, 0)); 39 } 13/6/15 10時49分 25
  • 26. 4.2bsd/sys/sys_inode.c 27 int ino_rw(), ino_ioctl(), ino_select(), ino_close(); 28 struct fileops inodeops = 29 { ino_rw, ino_ioctl, ino_select, ino_close }; 30 31 ino_rw(fp, rw, uio) 32 struct file *fp; 33 enum uio_rw rw; 34 struct uio *uio; 35 { 36 register struct inode *ip = (struct inode *)fp->f_data; 37 int error; 38 39 if ((ip->i_mode&IFMT) == IFREG) { 40 ILOCK(ip); 41 if (fp->f_flag&FAPPEND && rw == UIO_WRITE) 42 uio->uio_offset = fp->f_offset = ip->i_size; 43 error = rwip(ip, uio, rw); 44 IUNLOCK(ip); 45 } else 46 error = rwip(ip, uio, rw); 47 return (error); 48 } 49 13/6/15 10時49分 26
  • 27. 4.2bsd/sys/sys_inode.c 78 rwip(ip, uio, rw) 79 register struct inode *ip; 80 register struct uio *uio; 81 enum uio_rw rw; 82 { 126 do { 127 lbn = uio->uio_offset / bsize; 128 on = uio->uio_offset % bsize; 129 n = MIN((unsigned)(bsize - on), uio->uio_resid); 130 if (type != IFBLK) { 131 if (rw == UIO_READ) { 132 int diff = ip->i_size - uio->uio_offset; 133 if (diff <= 0) 134 return (0); 135 if (diff < n) 136 n = diff; 137 } 138 bn = fsbtodb(fs, 139 bmap(ip, lbn, rw == UIO_WRITE ? B_WRITE: B_READ, (int)(on+n))); 140 if (u.u_error || rw == UIO_WRITE && (long)bn<0) 141 return (u.u_error); 142 if (rw == UIO_WRITE && uio->uio_offset + n > ip->i_size && 143 (type == IFDIR || type == IFREG || type == IFLNK)) 144 ip->i_size = uio->uio_offset + n; 145 size = blksize(fs, ip, lbn); 146 } else { 147 bn = lbn * (BLKDEV_IOSIZE/DEV_BSIZE); 148 rablock = bn + (BLKDEV_IOSIZE/DEV_BSIZE); 149 rasize = size = bsize; 150 } 13/6/15 10時49分 27
  • 28. 4.2bsd/sys/ufs_bmap.c 28 bmap(ip, bn, rwflg, size) 29 register struct inode *ip; 30 daddr_t bn; 31 int rwflg; 32 int size; /* supplied only when rwflg == B_WRITE */ 33 { 34 register int i; 35 int osize, nsize; 36 struct buf *bp, *nbp; 37 struct fs *fs; 38 int j, sh; 39 daddr_t nb, lbn, *bap, pref, blkpref(); 40 45 fs = ip->i_fs; 46 rablock = 0; 47 rasize = 0; /* conservative */ 48 49 /* 50 * If the next write will extend the file into a new block, 51 * and the file is currently composed of a fragment 52 * this fragment has to be extended to be a full block. 53 */ 54 nb = lblkno(fs, ip->i_size); 55 if (rwflg == B_WRITE && nb < NDADDR && nb < bn) { 56 osize = blksize(fs, ip, nb); 57 if (osize < fs->fs_bsize && osize > 0) { 58 bp = realloccg(ip, ip->i_db[nb], 59 blkpref(ip, nb, (int)nb, &ip->i_db[0]), 60 osize, (int)fs->fs_bsize); 61 if (bp == NULL) 62 return ((daddr_t)-1); 63 ip->i_size = (nb + 1) * fs->fs_bsize; 64 ip->i_db[nb] = dbtofsb(fs, bp->b_blkno); 65 ip->i_flag |= IUPD|ICHG; 66 bdwrite(bp); 67 } 68 } 13/6/15 10時49分 28
  • 29. 4.2bsd/sys/ufs_alloc.c 107 struct buf * 108 realloccg(ip, bprev, bpref, osize, nsize) 109 register struct inode *ip; 110 daddr_t bprev, bpref; 111 int osize, nsize; 112 { 139 cg = dtog(fs, bprev); 140 bno = fragextend(ip, cg, (long)bprev, osize, nsize); 141 if (bno != 0) { 142 do { 143 bp = bread(ip->i_dev, fsbtodb(fs, bno), osize); 144 if (bp->b_flags & B_ERROR) { 145 brelse(bp); 146 return (NULL); 147 } 148 } while (brealloc(bp, nsize) == 0); 149 bp->b_flags |= B_DONE; 150 bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize); 151 ip->i_blocks += btodb(nsize - osize); 152 ip->i_flag |= IUPD|ICHG; 153 return (bp); 154 } 155 if (bpref >= fs->fs_size) 156 bpref = 0; 13/6/15 10時49分 29
  • 30. 4.2bsd/sys/ufs_alloc.c 481 fragextend(ip, cg, bprev, osize, nsize) 482 struct inode *ip; 483 int cg; 484 long bprev; 485 int osize, nsize; 486 { 510 bno = dtogd(fs, bprev); 511 for (i = numfrags(fs, osize); i < frags; i++) 512 if (isclr(cgp->cg_free, bno + i)) { 513 brelse(bp); 514 return (NULL); 515 } 516 /* 517 * the current fragment can be extended 518 * deduct the count on fragment being extended into 519 * increase the count on the remaining fragment (if any) 520 * allocate the extended piece 521 */ 522 for (i = frags; i < fs->fs_frag - bbase; i++) 523 if (isclr(cgp->cg_free, bno + i)) 524 break; 525 cgp->cg_frsum[i - numfrags(fs, osize)]--; 526 if (i != frags) 527 cgp->cg_frsum[i - frags]++; 528 for (i = numfrags(fs, osize); i < frags; i++) { 529 clrbit(cgp->cg_free, bno + i); 530 cgp->cg_cs.cs_nffree--; 531 fs->fs_cstotal.cs_nffree--; 532 fs->fs_cs(fs, cg).cs_nffree--; 533 } 534 fs->fs_fmod++; 535 bdwrite(bp); 536 return (bprev); 537 } 13/6/15 10時49分 30
  • 31. 4.2bsd/h/param.h 160 /* 161 * bit map related macros 162 */ 163 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 164 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 165 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 166 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 13/6/15 10時49分 31
  • 32. 4.2bsd/h/fs.h /* 230 * Cylinder group block for a file system. 231 */ 232 #define CG_MAGIC 0x090255 233 struct cg { 234 struct cg *cg_link; /* linked list of cyl groups */ 235 struct cg *cg_rlink; /* used for incore cyl groups */ 236 time_t cg_time; /* time last written */ 237 long cg_cgx; /* we are the cgx'th cylinder group */ 238 short cg_ncyl; /* number of cyl's this cg */ 239 short cg_niblk; /* number of inode blocks this cg */ 240 long cg_ndblk; /* number of data blocks this cg */ 241 struct csum cg_cs; /* cylinder summary information */ 242 long cg_rotor; /* position of last used block */ 243 long cg_frotor; /* position of last used frag */ 244 long cg_irotor; /* position of last used inode */ 245 long cg_frsum[MAXFRAG]; /* counts of available frags */ 246 long cg_btot[MAXCPG]; /* block totals per cylinder */ 247 short cg_b[MAXCPG][NRPOS]; /* positions of free blocks */ 248 char cg_iused[MAXIPG/NBBY]; /* used inode map */ 249 long cg_magic; /* magic number */ 250 u_char cg_free[1]; /* free block map */ 251 /* actually longer */ 252 }; 13/6/15 10時49分 32
  • 33. 4.2bsd/h/fs.h 129 /* 130 * Super block for a file system. 131 */ 132 #define FS_MAGIC 0x011954 133 struct fs 134 { 135 struct fs *fs_link; /* linked list of file systems */ 136 struct fs *fs_rlink; /* used for incore super blocks */ 137 daddr_t fs_sblkno; /* addr of super-block in filesys */ 138 daddr_t fs_cblkno; /* offset of cyl-block in filesys */ 139 daddr_t fs_iblkno; /* offset of inode-blocks in filesys */ 140 daddr_t fs_dblkno; /* offset of first data after cg */ 141 long fs_cgoffset; /* cylinder group offset in cylinder */ 142 long fs_cgmask; /* used to calc mod fs_ntrak */ 143 time_t fs_time; /* last time written */ 144 long fs_size; /* number of blocks in fs */ 145 long fs_dsize; /* number of data blocks in fs */ 146 long fs_ncg; /* number of cylinder groups */ 147 long fs_bsize; /* size of basic blocks in fs */ 148 long fs_fsize; /* size of frag blocks in fs */ 149 long fs_frag; /* number of frags in a block in fs */ 150 /* these are configuration parameters */ 154 /* these fields can be computed from the others */ 159 /* these are configuration parameters */ 162 /* these fields can be computed from the others */ 173 /* sizes determined by number of cylinder groups and their sizes */ 177 /* these fields should be derived from the hardware */ 181 /* this comes from the disk driver partitioning */ 183 /* these fields can be computed from the others */ 187 /* this data must be re-computed after crashes */ 189 /* these fields are cleared at mount time */ 195 /* these fields retain the current block allocation info */ 202 /* actually longer */ 203 }; 13/6/15 10時49分 33
  • 34. 媒体配置の改善 その2 • Cylinder Groupによる、シーク時間の改善 – Diskの大容量化、CPUの高速化でシーク時間の 影響が増大 – 1つのファイルには可能な限り近傍のブロックを 集めたい →Cylinder Group 13/6/15 10時49分 34
  • 35. Data Inode Cylinder group FS FFS data blocks Inode blocks Struct inode[] Super block Boot block Super block Boot block Cylinder group Data Inode Cylinder group FreeListは bitmap管理 13/6/15 10時49分 35
  • 36. h/inode.h 14 struct inode { 15 struct inode *i_chain[2]; /* must be first */ 16 u_short i_flag; 17 u_short i_count; /* reference count */ 18 dev_t i_dev; /* device where inode resides */ 19 u_short i_shlockc; /* count of shared locks on inode */ 20 u_short i_exlockc; /* count of exclusive locks on inode */ 21 ino_t i_number; /* i number, 1-to-1 with device address */ 22 struct fs *i_fs; /* file sys associated with this inode */ 23 struct dquot *i_dquot; /* quota structure controlling this file */ 24 union { 25 daddr_t if_lastr; /* last read (read-ahead) */ 26 struct socket *is_socket; 27 struct { 28 struct inode *if_freef; /* free list forward */ 29 struct inode **if_freeb; /* free list back */ 30 } i_fr; 31 } i_un; 32 struct icommon 33 { 34 u_short ic_mode; /* 0: mode and type of file */ 35 short ic_nlink; /* 2: number of links to file */ 36 short ic_uid; /* 4: owner's user id */ 37 short ic_gid; /* 6: owner's group id */ 38 quad ic_size; /* 8: number of bytes in file */ 39 time_t ic_atime; /* 16: time last accessed */ 40 long ic_atspare; 41 time_t ic_mtime; /* 24: time last modified */ 42 long ic_mtspare; 43 time_t ic_ctime; /* 32: last time inode changed */ 44 long ic_ctspare; 45 daddr_t ic_db[NDADDR]; /* 40: disk block addresses */ 46 daddr_t ic_ib[NIADDR]; /* 88: indirect blocks */ 47 long ic_flags; /* 100: status, currently unused */ 48 long ic_blocks; /* 104: blocks actually held */ 49 long ic_spare[5]; /* 108: reserved, currently unused */ 50 } i_ic; 51 }; 52 53 struct dinode { 54 union { 55 struct icommon di_icom; 56 char di_size[128]; 57 } di_un; 58 }; inode icommon struct dinode = struct icommon 13/6/15 10時49分 36
  • 37. Disk inode FSとFFSの違い FSのdisk inode 5605 struct inode 5606 { 5607 int i_mode; 5608 char i_nlink; 5609 char i_uid; 5610 char i_gid; 5611 char i_size0; 5612 char *i_size1; 5613 int i_addr[8]; 5614 int i_atime[2]; 5615 int i_mtime[2]; 5616 }; FFSのdisk inode 32 struct icommon 33 { 34 u_short ic_mode; /* 0: mode and type of file */ 35 short ic_nlink; /* 2: number of links to file */ 36 short ic_uid; /* 4: owner's user id */ 37 short ic_gid; /* 6: owner's group id */ 38 quad ic_size; /* 8: number of bytes in file */ 39 time_t ic_atime; /* 16: time last accessed */ 40 long ic_atspare; 41 time_t ic_mtime; /* 24: time last modified */ 42 long ic_mtspare; 43 time_t ic_ctime; /* 32: last time inode changed */ 44 long ic_ctspare; 45 daddr_t ic_db[NDADDR]; /* 40: disk block addresses */ 46 daddr_t ic_ib[NIADDR]; /* 88: indirect blocks */ 47 long ic_flags; /* 100: status, currently unused */ 48 long ic_blocks; /* 104: blocks actually held */ 49 long ic_spare[5]; /* 108: reserved, currently unused */ 50 } i_ic; 13/6/15 10時49分 37
  • 40. 異なるFSを利用するには? • FS毎に異なる構造・手続き – inodeの管理 – 名前の管理 – ブロックの管理 • VNODEの登場 – Incore InodeからFS依存部を取り除き、Inodeの操 作手続きを内包 13/6/15 10時49分 40
  • 42. Inode操作とvnode操作の違い 4.2bsd/sys/sys_inode.c 50 rdwri(rw, ip, base, len, offset, segflg, aresid) 51 struct inode *ip; 52 caddr_t base; 53 int len, segflg; 54 off_t offset; 55 int *aresid; 56 enum uio_rw rw; 57 { 58 struct uio auio; 59 struct iovec aiov; 60 int error; 61 62 auio.uio_iov = &aiov; 63 auio.uio_iovcnt = 1; 64 aiov.iov_base = base; 65 aiov.iov_len = len; 66 auio.uio_resid = len; 67 auio.uio_offset = offset; 68 auio.uio_segflg = segflg; 69 error = rwip(ip, &auio, rw); 70 if (aresid) 71 *aresid = auio.uio_resid; 72 else 73 if (auio.uio_resid) 74 error = EIO; 75 return (error); 76 } 4.3bsd_reno/kern/vfs_vnops.c 157 vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid) 158 enum uio_rw rw; 159 struct vnode *vp; 160 caddr_t base; 161 int len; 162 off_t offset; 163 enum uio_seg segflg; 164 int ioflg; 165 struct ucred *cred; 166 int *aresid; 167 { 168 struct uio auio; 169 struct iovec aiov; 170 int error; 171 172 if ((ioflg & IO_NODELOCKED) == 0) 173 VOP_LOCK(vp); 174 auio.uio_iov = &aiov; 175 auio.uio_iovcnt= 1; 176 aiov.iov_base = base; 177 aiov.iov_len = len; 178 auio.uio_resid = len; 179 auio.uio_offset = offset; 180 auio.uio_segflg = segflg; 181 auio.uio_rw = rw; 182 if (rw == UIO_READ) 183 error = VOP_READ(vp, &auio, ioflg, cred); 184 else 185 error = VOP_WRITE(vp,&auio, ioflg, cred); 186 if (aresid) 187 *aresid = auio.uio_resid; 188 else 189 if (auio.uio_resid && error == 0) 190 error = EIO; 191 if ((ioflg & IO_NODELOCKED) == 0) 192 VOP_UNLOCK(vp); 193 return (error); 194 } 13/6/15 10時49分 42
  • 43. VNODEの背景 • NFSの登場 – 4.3BSD Renoは公開プロトコルを利用した独自実 装を取り込んだ • read(2)->read()->vn_rdwr()->VOP_READ(vp) – vpがNFSのvnodeならnfs_read()が – vpがUSFのvnodeならufs_read()が 呼び出される 13/6/15 10時49分 43