Tag Archive for 'FreeBSD'

FreeBSD: policy routing with pf in 7-STABLE is BROKEN

pass in quick on $wan1 reply-to ($wan1 $wan1gw) from !$wan1net to ($wan1) keep state
pass out  route-to ($wan1 $wan1gw) proto {udp, icmp} from $wan1net to any no state
pass out  route-to ($wan1 $wan1gw) proto tcp from $wan1net to any flags any no state

In FreeBSD 7.0, the pf.conf above worked. But it doesn’t work in recent 7-STABLE. The TCP session may connect successfully, but the performance is very very poor (~ 1KB/s).

I have do some research for days, but have no idea. Now I use ipfw to do policy routing…

Bug in net/iscsi-target?

I found that the block count sent from net/iscsi-target to a initiator is round to 2^31:

(In FreeBSD, iSCSI Target)

Starting iscsi_target.
Reading configuration from `/usr/local/etc/iscsi/targets’
target0:rw:10.1.1.0/24
       extent0:/dev/stripe/gs0:0:2500582432768
DISK: 1 logical unit (4883950064 blocks, 512 bytes/block), type iscsi fs
DISK: LUN 0: 2384741 MB disk storage for “target0”
TARGET: TargetName is iqn.1994-04.org.netbsd.iscsi-target

(In Debian Linux, iSCSI initiator)

scsi 3:0:0:0: Direct-Access     NetBSD   NetBSD iSCSI     0    PQ: 0 ANSI: 3
sd 3:0:0:0: [sdc] 588982768 512-byte hardware sectors (301559 MB)
sd 3:0:0:0: [sdc] Write Protect is off
sd 3:0:0:0: [sdc] Mode Sense: 0e 00 00 08
sd 3:0:0:0: [sdc] Got wrong page
sd 3:0:0:0: [sdc] Assuming drive cache: write through
sd 3:0:0:0: [sdc] 588982768 512-byte hardware sectors (301559 MB)
sd 3:0:0:0: [sdc] Write Protect is off
sd 3:0:0:0: [sdc] Mode Sense: 0e 00 00 08
sd 3:0:0:0: [sdc] Got wrong page
sd 3:0:0:0: [sdc] Assuming drive cache: write through
sdc: unknown partition table
sd 3:0:0:0: [sdc] Attached SCSI disk

I don’t know if it is a iSCSI protocol or a implementation limitation.

FreeBSD: i386 inside a jail in amd64

The key point: make a symlink of jailed /libexec/ld-elf.so.1 to /libexec/ld-elf32.so.1. Of course, your kernel should have COMPAT_IA32 option compiled.

# cd /usr/src && make TARGET_ARCH=i386 TARGET=i386 buildworld
# mkdir -p /home/jails/i386 && make TARGET_ARCH=i386 TARGET=i386 DESTDIR=/home/jails/i386 installworld
# make TARGET_ARCH=i386 TARGET=i386 DESTDIR=/home/jails/i386 distribution
# ln -s /home/jails/i386/libexec/ld-elf.so.1 /home/jails/i386/libexec/ld-elf32.so.1

Then, edit rc.conf in jail to run sshd and start jails. Some utilities, like w/ps/top can not run because they retrieve data from FreeBSD kernel, and the kernel returns 64-bit structures, not 32-bit.

w
4:37AM  up 12 days,  8:40, 1 user, load averages: 0.03, 0.18, 0.20
USER             TTY      FROM              LOGIN@  IDLE WHAT
w: kinfo_proc size mismatch (expected 768, got 1088): No such file or directory

I am doing further test to make sure there aren’t any mines :)

FreeBSD: Use ZFS volume as an iSCSI Target

Briefly, we can set the extent of iscsi-target to a ZFS volume…
But I have no idea what will happen if the size of extent is larger than it of the ZFS volume…:)

# zfs create -V 10g tank/iscsi
# cd /usr/ports/net/iscsi-target/ ; make install clean
# cat > /usr/local/etc/iscsi/targets
extent0         /dev/zvol/tank/iscsi     0       10GB
target0         rw      extent0         10.0.0.0/24
^D
# /usr/local/etc/rc.d/iscsi_target forcestart

Now we can connect this iSCSI Target with some iSCSI initiator.

FreeBSD: vfs.read_max for Hardware RAID

Tested with: bonnie -s 2048, FreeBSD 7.0 UFS2 , Hardware RAID 5 (6 PATA 7200rpm 250G disks)
vfs.read_max=8 (default)

-------Sequential Output--------
-Per Char- --Block--- -Rewrite--
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU
2048 25812 24.8 26483 6.6 13886 4.4
---Sequential Input-- --Random--
-Per Char- --Block--- --Seeks---
K/sec %CPU K/sec %CPU /sec %CPU
32162 32.5 33386 5.1 232.3 1.5

vfs.read_mas=128

-------Sequential Output--------
-Per Char- --Block--- -Rewrite--
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU
2048 25380 24.3 25949 6.5 13956 4.3
---Sequential Input-- --Random--
-Per Char- --Block--- --Seeks---
K/sec %CPU K/sec %CPU /sec %CPU
41060 43.4 42839 8.3 224.9 1.4

vfs.read_max=256

-------Sequential Output--------
-Per Char- --Block--- -Rewrite--
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU
2048 25714 24.3 25939 6.5 13966 4.3
---Sequential Input-- --Random--
-Per Char- --Block--- --Seeks---
K/sec %CPU K/sec %CPU /sec %CPU
41442 43.8 43737 8.6 225.2 1.5

Conclusion: No performance gain on random access, but about 25% better sequential read performance.

FreeBSD: Set the order of SCSI Cards

In /boot/device.hints:

hint.scbus.0.at="ahd0"

FreeBSD gjournal and UFS snapshot

Recently I am testing a new feature in FreeBSD 7.0: gjournal. However, taking a snapshot on a journalized ufs causes kernel panic. (Size of the RAID is 5TB)

panic

And I cannot write into the filesystem when I am taking a snapshot, and ever can not read data from it. We should use ZFS or NetApp when we need filesystem snapshot in FreeBSD…