I''m interested in creating a read-only vdev or adding in the ability to disallow writes to a particular vdev within a pool. So, if there were two device nodes: d1 and d2 inside of a pool, I''d like to restrict writing to d1 and force all writes to go to d2. Initially, I attempted to manipulate vdev_t spa_root_vdev -> vdev_stat_t vdev_stat -> vs_alloc. I set vs_alloc = vs_space (hoping this would prevent further writes to the particular vdev). This resulted in zpool list displaying incorrect values in the "used" column but not restricting writes. I am currently looking at the ZIO code to tackle my problem. I am trying to find how this layer tracks the free blocks (I think this is done w/ trees). I''d like to mark all the blocks as written to prevent writes to a particular vdev. Any suggestions on how to tackle this would be greatly appreciated ~Mike -- This message posted from opensolaris.org
After a little more review of the source - I think I want to take the DVA (Data Virtual Address - which consists of a vdev / offset combination) and force all the vdevs to always resolve to vdev2 on writes (rather than vdev1). Later, I can go back and try to add an attribute to a vdev which will disallow it to be written to during DVA. Any thoughts or insights on this approach are most welcome, ~Mike -- This message posted from opensolaris.org
So I think I''ve found where the vdev is selected for writes to take place. In src/lib/libzpool/metaslab.c there is a function metaslab_alloc_dva(). The vdev that is selected to write to is vdev_t vd. I''m not entirely sure how it is selected, but I have the guid of the vdev that I don''t want written to: #define READ_ONLY_GUID 0x123456789 if(vd->vdev_guid == READ_ONLY_GUID) { // code to select another vdev } I''ve temporarily stuck in some debug statements to see what''s going on and I''ve noticed that slabs are allocated on import. I was under the impression only the vdev labels (which I don''t think are objects and were written to directly) were affected at this point. Not entirely sure why slabs are being allocated here? ~Mike -- This message posted from opensolaris.org