| 2953 | } |
| 2954 | |
| 2955 | void |
| 2956 | zil_commit_impl(zilog_t *zilog, uint64_t foid) |
| 2957 | { |
| 2958 | ZIL_STAT_BUMP(zil_commit_count); |
| 2959 | |
| 2960 | /* |
| 2961 | * Move the "async" itxs for the specified foid to the "sync" |
| 2962 | * queues, such that they will be later committed (or skipped) |
| 2963 | * to an lwb when zil_process_commit_list() is called. |
| 2964 | * |
| 2965 | * Since these "async" itxs must be committed prior to this |
| 2966 | * call to zil_commit returning, we must perform this operation |
| 2967 | * before we call zil_commit_itx_assign(). |
| 2968 | */ |
| 2969 | zil_async_to_sync(zilog, foid); |
| 2970 | |
| 2971 | /* |
| 2972 | * We allocate a new "waiter" structure which will initially be |
| 2973 | * linked to the commit itx using the itx's "itx_private" field. |
| 2974 | * Since the commit itx doesn't represent any on-disk state, |
| 2975 | * when it's committed to an lwb, rather than copying the its |
| 2976 | * lr_t into the lwb's buffer, the commit itx's "waiter" will be |
| 2977 | * added to the lwb's list of waiters. Then, when the lwb is |
| 2978 | * committed to stable storage, each waiter in the lwb's list of |
| 2979 | * waiters will be marked "done", and signalled. |
| 2980 | * |
| 2981 | * We must create the waiter and assign the commit itx prior to |
| 2982 | * calling zil_commit_writer(), or else our specific commit itx |
| 2983 | * is not guaranteed to be committed to an lwb prior to calling |
| 2984 | * zil_commit_waiter(). |
| 2985 | */ |
| 2986 | zil_commit_waiter_t *zcw = zil_alloc_commit_waiter(); |
| 2987 | zil_commit_itx_assign(zilog, zcw); |
| 2988 | |
| 2989 | zil_commit_writer(zilog, zcw); |
| 2990 | zil_commit_waiter(zilog, zcw); |
| 2991 | |
| 2992 | if (zcw->zcw_zio_error != 0) { |
| 2993 | /* |
| 2994 | * If there was an error writing out the ZIL blocks that |
| 2995 | * this thread is waiting on, then we fallback to |
| 2996 | * relying on spa_sync() to write out the data this |
| 2997 | * thread is waiting on. Obviously this has performance |
| 2998 | * implications, but the expectation is for this to be |
| 2999 | * an exceptional case, and shouldn't occur often. |
| 3000 | */ |
| 3001 | DTRACE_PROBE2(zil__commit__io__error, |
| 3002 | zilog_t *, zilog, zil_commit_waiter_t *, zcw); |
| 3003 | txg_wait_synced(zilog->zl_dmu_pool, 0); |
| 3004 | } |
| 3005 | |
| 3006 | zil_free_commit_waiter(zcw); |
| 3007 | } |
| 3008 | |
| 3009 | /* |
| 3010 | * Called in syncing context to free committed log blocks and update log header. |
no test coverage detected