2009.07.11 ATA to CAM integration に挑戦 FreeBSD 8.0 の目玉の一つ, 宿願(3.0 以来?)の ATA の CAM 化に挑戦 してみました。とは言え, CAM 化されたのは AHCI (Advanced Host Controller Interface)のみで, 従来の ATA インターフェースは対象 になっていません。つまり ataahci(4) で認識しているデバイスが対 象となります。作業にあたってはいくつかの慎重な手順を踏んで行っ ています。結構危険な作業であることを意識しましょう:-)。 1. 従来の ata(4) な環境(カーネル/ソース)が安定していることを確認 する。またそのカーネルで立ち上げておく(バックアップしておくこ とも重要)。 2. 影響範囲の調査。最低でも /etc/fstab はチェック。おそらくはデ ィスクのデバイス名を直接見るようなものは無いと思うけど…。 あと smartmontools が使えなくなるという話なので, これは別途 要調査ですね。/usr/local/etc/smartd.conf の中身をチェックし ましょう。まぁ単純に smartctl -a -d scsi /dev/ada0 で core 吐 いてくれるので, そもそも…。。 orz 3. /etc/fstab ネタは最悪, root パーティションの指定をしくる可能 性があるので, 代替手段を覚えておくこと。 loader が立ち上がった段階で下記の設定を行う(この辺は自分の環 境の /etc/fstab を見て調整すること)。 set vfs.root.mountfrom=ufs:/dev/ad0s1a set vfs.root.mountfrom.options=rw,noatime 当然シングルユーザーモードで起動だ! boot -s 4. ata(4) を無効にして cam(4) 化 GENERIC カーネルだと下記設定があるのでこれを無効にし, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ATA and ATAPI devices device ata device atadisk # ATA disk drives device ataraid # ATA RAID drives device atapicd # ATAPI CDROM drives device atapifd # ATAPI floppy drives device atapist # ATAPI tape drives options ATA_STATIC_ID # Static device numbering - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 代わりに下記設定を追加します。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - device ahci # AHCI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GENERIC を想定してるので上記追加で問題ありませんが, カス タマイズカーネルで色々しぼってるなら, 下記設定も必須とな ります。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SCSI peripherals device scbus # SCSI bus (required for SCSI) device da # Direct Access (disks) device cd # CD device pass # Passthrough device (direct SCSI access) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 現時点ではディスクと CD が対応しています。sa (テープデバイ ス)等の特殊なデバイスでどうなるかわかりません。 この手の設定で意外と忘れられるのが pass(4) で, これがないと SCSI の制御系コマンドが使えません。 5. 上記カーネルをインストールして再起動 とりあえず自分のところの環境(ZFS Boot)では問題なく切り替わっ てくれました:-)。ZFS ばんざーい。 boot -v した時の起動メッセージの一部(ahci に関するメッセージを抽出) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ahci0: port 0xa000-0xa007,0x9000-0x9003,0x8000-0x8007,0x7000-0x7003,0x6000-0x600f mem 0xfb8fe400-0xfb8fe7ff irq 22 at device 17.0 on pci0 ahci0: Reserved 0x400 bytes for rid 0x24 type 3 at 0xfb8fe400 ahci0: [MPSAFE] ahci0: [ITHREAD] ahci0: AHCI v1.10 with 6 3Gbps ports, Port Multiplier supported ahci0: Caps: 64bit NCQ SNTF MPS ALP AL CLO 3Gbps PM PMD SSC PSC 32cmd CCC 6ports ahcich0: at channel 0 on ahci0 ahcich0: [MPSAFE] ahcich0: [ITHREAD] ahcich1: at channel 1 on ahci0 ahcich1: [MPSAFE] ahcich1: [ITHREAD] ahcich2: at channel 2 on ahci0 ahcich2: [MPSAFE] ahcich2: [ITHREAD] ahcich3: at channel 3 on ahci0 ahcich3: [MPSAFE] ahcich3: [ITHREAD] ahcich4: at channel 4 on ahci0 ahcich4: [MPSAFE] ahcich4: [ITHREAD] ahcich5: at channel 5 on ahci0 ahcich5: [MPSAFE] ahcich5: [ITHREAD] ahcich0: AHCI reset... ahcich0: hardware reset ... ahcich0: SATA connect time=0ms status=00000123 ahcich0: ready wait time=0ms ahcich0: AHCI reset done: devices=00000001 ahcich1: AHCI reset... ahcich1: hardware reset ... ahcich1: SATA connect time=0ms status=00000123 ahcich1: ready wait time=0ms ahcich1: AHCI reset done: devices=00000001 ahcich2: AHCI reset... ahcich2: hardware reset ... ahcich2: SATA connect time=0ms status=00000123 ahcich2: ready wait time=0ms ahcich2: AHCI reset done: devices=00000001 ahcich3: AHCI reset... ahcich3: hardware reset ... ahcich3: SATA connect time=0ms status=00000123 ahcich3: ready wait time=0ms ahcich3: AHCI reset done: devices=00000001 ahcich4: AHCI reset... ahcich4: hardware reset ... ahcich4: SATA connect timeout status=00000000 ahcich4: AHCI reset done: phy reset found no device ahcich5: AHCI reset... ahcich5: hardware reset ... ahcich5: SATA connect timeout status=00000000 ahcich5: AHCI reset done: phy reset found no device ahcich0: Poll timeout on slot 2 (probe0:ahcich0:0:15:0): Command timed out (probe0:ahcich0:0:15:0): error 5 (probe0:ahcich0:0:15:0): Retries Exhausted (probe0:ahcich0:0:0:0): SIGNATURE: 0000 ahcich1: Poll timeout on slot 2 (probe1:ahcich1:0:15:0): Command timed out (probe1:ahcich1:0:15:0): error 5 (probe1:ahcich1:0:15:0): Retries Exhausted (probe0:ahcich1:0:0:0): SIGNATURE: 0000 ahcich2: Poll timeout on slot 2 (probe2:ahcich2:0:15:0): Command timed out (probe2:ahcich2:0:15:0): error 5 (probe2:ahcich2:0:15:0): Retries Exhausted (probe0:ahcich2:0:0:0): SIGNATURE: 0000 ahcich3: Poll timeout on slot 2 (probe3:ahcich3:0:15:0): Command timed out (probe3:ahcich3:0:15:0): error 5 (probe3:ahcich3:0:15:0): Retries Exhausted (probe0:ahcich3:0:0:0): SIGNATURE: 0000 ada0 at ahcich0 bus 0 target 0 lun 0 ada0: ATA/ATAPI-7 SATA 2.x device ada0: Serial Number CVEM9024016B064KGN ada0: 300.000MB/s transfers ada0: 61057MB (125045424 512 byte sectors: 16H 63S/T 16383C) ada1 at ahcich1 bus 0 target 0 lun 0 ada1: ATA/ATAPI-8 SATA 2.x device ada1: Serial Number WD-WCAU45664302 ada1: 300.000MB/s transfers ada1: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C) ada1: Native Command Queueing enabled ada2 at ahcich2 bus 0 target 0 lun 0 ada2: ATA/ATAPI-7 SATA 2.x device ada2: Serial Number CVEM902100VS064KGN ada2: 300.000MB/s transfers ada2: 61057MB (125045424 512 byte sectors: 16H 63S/T 16383C) ada3 at ahcich3 bus 0 target 0 lun 0 ada3: ATA/ATAPI-8 SATA 2.x device ada3: Serial Number WD-WCAU45698264 ada3: 300.000MB/s transfers ada3: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C) ada3: Native Command Queueing enabled pass0 at ahcich0 bus 0 target 0 lun 0 pass0: ATA/ATAPI-7 SATA 2.x device pass0: Serial Number CVEM9024016B064KGN pass0: 300.000MB/s transfers pass1 at ahcich1 bus 0 target 0 lun 0 pass1: ATA/ATAPI-8 SATA 2.x device pass1: Serial Number WD-WCAU45664302 pass1: 300.000MB/s transfers pass2 at ahcich2 bus 0 target 0 lun 0 pass2: ATA/ATAPI-7 SATA 2.x device pass2: Serial Number CVEM902100VS064KGN pass2: 300.000MB/s transfers pass3 at ahcich3 bus 0 target 0 lun 0 pass3: ATA/ATAPI-8 SATA 2.x device pass3: Serial Number WD-WCAU45698264 pass3: 300.000MB/s transfers GEOM: new disk ada0 GEOM: new disk ada1 GEOM: new disk ada2 GEOM: new disk ada3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - このあたりの認識は下記のような対応で変化しています。 HDD 物理接続ポート ataahci(4) on ata(4) ahci(4) on cam(4) SATA ポート 1 → ad4 → ada0 SATA ポート 2 → ad8 → ada2 SATA ポート 3 → ad6 → ada1 SATA ポート 4 → ad10 → ada3 私自身は 4 台しか HDD(SSD?) をつなげてないので, これ以上つなげ るとどうなるか分からないのと, CD ドライブ(SATA 接続タイプのも の, もちろん DVD, BR タイプのドライブが標準的かと)を付けた場合 もどうなるかわかりません。またこの並びもチップ(AMD SB750)の問題 なのかマザーボード(ASUS M4A79 Deluxe)の問題か, AHCI の仕様かは 分かっていません。 まぁそれはそれとしてアレだ。NCQ (Native Command Queueing)。SCSI だと TCQ (Tagged Command Queueing) として有名なメカニズムがやっ と FreeBSD でも使えるようになったところ。まぁ NCQ については下 記の URL でメカニズムが紹介されてるので詳細はそっちを見てもらう として, SEE ALSO: http://pc.watch.impress.co.jp/docs/2003/1208/it012.htm やっぱ # camcontrol devlist at scbus0 target 0 lun 0 (pass0,ada0) at scbus1 target 0 lun 0 (pass1,ada1) at scbus2 target 0 lun 0 (pass2,ada2) at scbus3 target 0 lun 0 (pass3,ada3) # camcontrol tags ada0 (pass0:ahcich0:0:0:0): device openings: 32 と camcontrol(8) で SATA な HDD アクセスできることっすよ。ちな みに cd(4) で認識された場合, burncd(8) が使えなくなるので cdrtools (特に ports/sysutils/cdrtools-devel, これは DVD 等のメディアにも 対応してる)の cdrecord を使用することになる。 さて。CAM 化されたために, デバイス番号の割り当てについて, 本家で議 論がされています。個人的には da0, ... で認識されなかった分だけマシ だと思っていたのだけど, ディスク追加しただけでずれるぞ!というので あればちょっとは考えないといけないところ。 検証はしてないけど, device hinting の仕組みで固定することはできる んではないかなと考えてる。実際 ad4, ad8, ad6, ad10 で認識してたも のを ada4, ada8, ada6, ada10 で認識させるなら下記のような設定を行 うことになるであろうと思われる(検証しなさい > 自分)。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - hint.scbus.0.at="ahcich0" hint.scbus.0.bus="0" hint.scbus.1.at="ahcich1" hint.scbus.1.bus="1" hint.scbus.2.at="ahcich2" hint.scbus.2.bus="2" hint.scbus.3.at="ahcich3" hint.scbus.3.bus="3" hint.ada.4.at="scbus0" hint.ada.4.target="0" hint.ada.4.unit="0" hint.ada.8.at="scbus1" hint.ada.8.target="0" hint.ada.8.unit="0" hint.ada.6.at="scbus2" hint.ada.6.target="0" hint.ada.6.unit="0" hint.ada.10.at="scbus3" hint.ada.10.target="0" hint.ada.10.unit="0" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - まぁ敢えてどこで設定するとか, device hinting って何とか, そのあ たりについては書かないことにしておく:D。 > cam(4) さて。現時点で分かってる問題としては zdb Zプール が使えないこと かな。最近の修正で zdb で core 吐かなくなったのですが, デバイス 情報を更新できないため, 個別にストレージにアクセスできないよう です。さて。どうやって修正したものか。。 > /boot/zfs/zpool.cache # zdb zoot version=13 name='zoot' state=0 txg=252356 pool_guid=15462925786868221657 hostid=1313438227 hostname='nadesico.ninth-nine.com' vdev_tree type='root' id=0 guid=15462925786868221657 children[0] type='mirror' id=0 guid=13132171314076037476 metaslab_array=23 metaslab_shift=29 ashift=9 asize=64018186240 is_log=0 children[0] type='disk' id=0 guid=9598577313381352861 path='/dev/ad4p2' whole_disk=0 DTL=482 children[1] type='disk' id=1 guid=18224282133046551518 path='/dev/ad8p2' whole_disk=0 DTL=481 zdb: can't open zoot: No such file or directory まぁ手段を選ばなければ, 直せなくもないけど…。。ahci(4) 有効 にした USB デバイスで boot させた後 zpool import した時の zpool.cache で上書くとか:-)。 Written by 重村法克