xfs_trans.h (61c1e689fbde7cb50a76262bba190715d86beab6) xfs_trans.h (a844f4510dce23c07f3923cb42138f5fdd745017)
1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but

--- 220 unchanged lines hidden (view full) ---

229
230
231/*
232 * Initialize the given chunk. Set the chunk's free descriptor mask
233 * to indicate that all descriptors are free. The caller gets to set
234 * lic_unused to the right value (0 matches all free). The
235 * lic_descs.lid_index values are set up as each desc is allocated.
236 */
1/*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but

--- 220 unchanged lines hidden (view full) ---

229
230
231/*
232 * Initialize the given chunk. Set the chunk's free descriptor mask
233 * to indicate that all descriptors are free. The caller gets to set
234 * lic_unused to the right value (0 matches all free). The
235 * lic_descs.lid_index values are set up as each desc is allocated.
236 */
237#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_INIT)
238void xfs_lic_init(xfs_log_item_chunk_t *cp);
239#define XFS_LIC_INIT(cp) xfs_lic_init(cp)
237#define XFS_LIC_INIT(cp) xfs_lic_init(cp)
240#else
241#define XFS_LIC_INIT(cp) ((cp)->lic_free = XFS_LIC_FREEMASK)
242#endif
243#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_INIT_SLOT)
244void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot);
238static inline void xfs_lic_init(xfs_log_item_chunk_t *cp)
239{
240 cp->lic_free = XFS_LIC_FREEMASK;
241}
242
245#define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot)
243#define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot)
246#else
247#define XFS_LIC_INIT_SLOT(cp,slot) \
248 ((cp)->lic_descs[slot].lid_index = (unsigned char)(slot))
249#endif
250#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_VACANCY)
251int xfs_lic_vacancy(xfs_log_item_chunk_t *cp);
244static inline void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot)
245{
246 cp->lic_descs[slot].lid_index = (unsigned char)(slot);
247}
248
252#define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp)
249#define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp)
253#else
254#define XFS_LIC_VACANCY(cp) (((cp)->lic_free) & XFS_LIC_FREEMASK)
255#endif
256#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ALL_FREE)
257void xfs_lic_all_free(xfs_log_item_chunk_t *cp);
250static inline int xfs_lic_vacancy(xfs_log_item_chunk_t *cp)
251{
252 return cp->lic_free & XFS_LIC_FREEMASK;
253}
254
258#define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp)
255#define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp)
259#else
260#define XFS_LIC_ALL_FREE(cp) ((cp)->lic_free = XFS_LIC_FREEMASK)
261#endif
262#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ARE_ALL_FREE)
263int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp);
256static inline void xfs_lic_all_free(xfs_log_item_chunk_t *cp)
257{
258 cp->lic_free = XFS_LIC_FREEMASK;
259}
260
264#define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp)
261#define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp)
265#else
266#define XFS_LIC_ARE_ALL_FREE(cp) (((cp)->lic_free & XFS_LIC_FREEMASK) ==\
267 XFS_LIC_FREEMASK)
268#endif
269#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ISFREE)
270int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot);
262static inline int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp)
263{
264 return ((cp->lic_free & XFS_LIC_FREEMASK) == XFS_LIC_FREEMASK);
265}
266
271#define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot)
267#define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot)
272#else
273#define XFS_LIC_ISFREE(cp,slot) ((cp)->lic_free & (1 << (slot)))
274#endif
275#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_CLAIM)
276void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot);
268static inline int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot)
269{
270 return (cp->lic_free & (1 << slot));
271}
272
277#define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot)
273#define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot)
278#else
279#define XFS_LIC_CLAIM(cp,slot) ((cp)->lic_free &= ~(1 << (slot)))
280#endif
281#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_RELSE)
282void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot);
274static inline void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot)
275{
276 cp->lic_free &= ~(1 << slot);
277}
278
283#define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot)
279#define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot)
284#else
285#define XFS_LIC_RELSE(cp,slot) ((cp)->lic_free |= 1 << (slot))
286#endif
287#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_SLOT)
288xfs_log_item_desc_t *xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot);
280static inline void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot)
281{
282 cp->lic_free |= 1 << slot;
283}
284
289#define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot)
285#define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot)
290#else
291#define XFS_LIC_SLOT(cp,slot) (&((cp)->lic_descs[slot]))
292#endif
293#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_DESC_TO_SLOT)
294int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp);
286static inline xfs_log_item_desc_t *
287xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot)
288{
289 return &(cp->lic_descs[slot]);
290}
291
295#define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp)
292#define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp)
296#else
297#define XFS_LIC_DESC_TO_SLOT(dp) ((uint)((dp)->lid_index))
298#endif
293static inline int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp)
294{
295 return (uint)dp->lid_index;
296}
297
299/*
300 * Calculate the address of a chunk given a descriptor pointer:
301 * dp - dp->lid_index give the address of the start of the lic_descs array.
302 * From this we subtract the offset of the lic_descs field in a chunk.
303 * All of this yields the address of the chunk, which is
304 * cast to a chunk pointer.
305 */
298/*
299 * Calculate the address of a chunk given a descriptor pointer:
300 * dp - dp->lid_index give the address of the start of the lic_descs array.
301 * From this we subtract the offset of the lic_descs field in a chunk.
302 * All of this yields the address of the chunk, which is
303 * cast to a chunk pointer.
304 */
306#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_DESC_TO_CHUNK)
307xfs_log_item_chunk_t *xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp);
308#define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp)
305#define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp)
309#else
310#define XFS_LIC_DESC_TO_CHUNK(dp) ((xfs_log_item_chunk_t*) \
311 (((xfs_caddr_t)((dp) - (dp)->lid_index)) -\
312 (xfs_caddr_t)(((xfs_log_item_chunk_t*) \
313 0)->lic_descs)))
314#endif
306static inline xfs_log_item_chunk_t *
307xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp)
308{
309 return (xfs_log_item_chunk_t*) \
310 (((xfs_caddr_t)((dp) - (dp)->lid_index)) - \
311 (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs));
312}
315
316#ifdef __KERNEL__
317/*
318 * This structure is used to maintain a list of block ranges that have been
319 * freed in the transaction. The ranges are listed in the perag[] busy list
320 * between when they're freed and the transaction is committed to disk.
321 */
322
323typedef struct xfs_log_busy_slot {
324 xfs_agnumber_t lbc_ag;
325 ushort lbc_idx; /* index in perag.busy[] */
326} xfs_log_busy_slot_t;
327
328#define XFS_LBC_NUM_SLOTS 31
329typedef struct xfs_log_busy_chunk {
330 struct xfs_log_busy_chunk *lbc_next;
313
314#ifdef __KERNEL__
315/*
316 * This structure is used to maintain a list of block ranges that have been
317 * freed in the transaction. The ranges are listed in the perag[] busy list
318 * between when they're freed and the transaction is committed to disk.
319 */
320
321typedef struct xfs_log_busy_slot {
322 xfs_agnumber_t lbc_ag;
323 ushort lbc_idx; /* index in perag.busy[] */
324} xfs_log_busy_slot_t;
325
326#define XFS_LBC_NUM_SLOTS 31
327typedef struct xfs_log_busy_chunk {
328 struct xfs_log_busy_chunk *lbc_next;
331 uint lbc_free; /* bitmask of free slots */
329 uint lbc_free; /* free slots bitmask */
332 ushort lbc_unused; /* first unused */
333 xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
334} xfs_log_busy_chunk_t;
335
336#define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1)
337#define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1)
338
339#define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK)

--- 694 unchanged lines hidden ---
330 ushort lbc_unused; /* first unused */
331 xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
332} xfs_log_busy_chunk_t;
333
334#define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1)
335#define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1)
336
337#define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK)

--- 694 unchanged lines hidden ---