Forgive my ignorance, but what''s the call path from libzfs_dataset.c/zfs_snapshot() to dsl_dataset.c/dsl_dataset_snapshot_sync()? I can''t find either any static calls or indirection through function pointers to establish the path, but surely the former has got to invoke the latter somewhere along the way. This message posted from opensolaris.org
Matthew Ahrens
2005-Dec-16 22:02 UTC
[zfs-discuss] I do not understand the ZFS source code
On Fri, Dec 16, 2005 at 12:32:00PM -0800, Andrew wrote:> Forgive my ignorance, but what''s the call path from > libzfs_dataset.c/zfs_snapshot() to > dsl_dataset.c/dsl_dataset_snapshot_sync()? I can''t find either any > static calls or indirection through function pointers to establish the > path, but surely the former has got to invoke the latter somewhere > along the way.There are three important execution contexts in this code path: userland, kernel in ZFS open context, and kernel in ZFS syncing context. Syncing context is when ZFS is actually writing out changes to disk, whereas in open context we just make a note of changes that need to be written out (and write to the intent log). Some things need to be done in a certain context, and you can''t directly call from one context to another, so the code path may not be immediately obvious. zfs(1m) calls zfs_snapshot() in userland, which does a ZFS_IOC_CREATE ioctl. In the kernel, the ioctl framework will call zfsdev_ioctl(), which will call zfs_ioc_create() through the function pointer in the zfs_ioc_vec table. zfs_ioc_create() calls dmu_objset_create(), which calls dsl_dir_sync_task() with a callback of dsl_dataset_snapshot_sync(). Then in syncing context, dsl_dir_sync() will call dsl_dataset_snapshot_sync() through the dd_sync_func function pointer. The changes that dsl_dataset_snapshot_sync() makes will be written later on in this syncing phase, when we sync out the MOS. Hope that helps, --matt
Matthew Ahrens wrote: [snip]> dmu_objset_create(), which calls > dsl_dir_sync_task() with a callback of dsl_dataset_snapshot_sync().Thanks. Trying to search backwards from dsl_dataset_snapshot_sync() to determine the call path, I did a google search for site:cvs.opensolaris.org dsl_dataset_snapshot_sync and found references in three .c files: dsl_dataset.c, dmu.c, and dmu_objset.c. I searched backwards from the references in the first two, and found no path to zfs_snapshot(), but I forgot to check the third--which is where (naturally) dmu_objset_create() lives, and from which I would have found the path. So I got stumped. The lesson is, I can''t count to three. :) This message posted from opensolaris.org