キャッシュサーバの squid の coss というファイルシステムが良い感じという噂をもとに、どういうものなのかチラ見してみようと思い、いじってみることに
会社に出社したけど暇なので調べていた。 こんな感じにビルド。
./configure --enable-storeio="ufs aufs coss" make
--enable-storeio= でキャッシュに使うファイルシステムを指定します。 coss を使うときには aufs も同時に指定しないと aio* な関数が undefined になるので同時指定が必要です。
とりあえずビルドはできたのですが、COSSを使ったファイルシステムの設定・構築の方法を調べるのが面倒だったので、後回し。 COSS のソース読んでどのようなAPIになっているのか見てみたところ、こんなインターフェースが準備されていると思ってよいのかな。
$ less src/fs/coss/store_coss.h ... 省略 ... #define SWAPDIR_COSS "coss"
#if USE_AUFSOPS /* XXX a hack; the async ops should be broken out! */ typedef void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno); void aioWrite(int, off_t offset, char *, int size, AIOCB *, void *, FREE *); void aioRead(int, off_t offset, int size, AIOCB *, void *); void aioInit(void); int aioCheckCallbacks(SwapDir *); void aioSync(SwapDir *); void squidaio_init(void); void squidaio_shutdown(void); extern int squidaio_magic1; int aioQueueSize(void); extern int squidaio_magic1; #define MAGIC1 squidaio_magic1 #endif ... 省略 ... extern void storeCossAdd(SwapDir * sd, StoreEntry * e, int curstripe); extern void storeCossRemove(SwapDir *, StoreEntry *); extern void storeCossStartMembuf(SwapDir * SD); extern void membufsDump(CossInfo * cs, StoreEntry * e); extern void storeCossFreeDeadMemBufs(CossInfo * cs); extern int storeCossFilenoToStripe(CossInfo * cs, sfileno filen); extern char const *stripePath(SwapDir * sd);
extern struct _coss_stats coss_stats;
構造体 SwapDir, StoreEntry などが squid の本体側のソースでも多用されているところを見ると、これらの関数が COSS の RW のAPIと見てもよいのかな。
で、いくつかの種類のファイルシステムをサポートしているってことは、どっかでデバイスドライバのレジストみたいなことしているはずだよなと思い、追いかけたところ store_dir_coss.c 内でこのような部分を発見
void
storeFsSetup_coss(storefs_entry_t * storefs)
{
assert(!coss_initialised);
storefs->parsefunc = storeCossDirParse;
storefs->reconfigurefunc = storeCossDirReconfigure;
storefs->donefunc = storeCossDirDone;
coss_state_pool = memPoolCreate("COSS IO State data", sizeof(CossState));
coss_index_pool = memPoolCreate("COSS index data", sizeof(CossIndexNode));
coss_realloc_pool = memPoolCreate("COSS pending realloc", sizeof(CossPending
Reloc));
coss_op_pool = memPoolCreate("COSS pending operation", sizeof(CossReadOp));
cachemgrRegister(SWAPDIR_COSS, "COSS Stats", storeCossStats, 0, 1);
coss_initialised = 1;
}
構造体
某所から coss の機能を apache に移植できたらカッコいいよねとかいうこと言われて挑発されて(笑)いるのですが、このモジュールのレジスト部分から機能を洗い出して、適当なところで apache DSO module にくっつけるコネクタみたいなのをくっつければいいのか。 こんな継ぎ接ぎ手法でできるかどうかの判断は、もうちょいソース追っかけてからにでも判断しよう。
今月中くらいまでにお願いします(・∀・ )っ/凵⌒☆チンチン
今月は全体的に暇なので、まったりやっています。 ただ apache に移植するのは結構面倒な作業が多そうです。 squid の中で使っている構造体を、apache で使えるように良く似たものを作るみたいな作業があるんで。