Commit 83f92318 authored by Mark Fasheh's avatar Mark Fasheh Committed by Joel Becker
Browse files

ocfs2: Add dir_resv_level mount option



The default behavior for directory reservations stays the same, but we add a
mount option so people can tweak the size of directory reservations
according to their workloads.

Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent b07f8f24
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -83,3 +83,7 @@ noacl (*) Disables POSIX Access Control Lists support.
resv_level=2	(*)	Set how agressive allocation reservations will be.
			Valid values are between 0 (reservations off) to 8
			(maximum space for reservations).
dir_resv_level=	(*)	By default, directory reservations will scale with file
			reservations - users should rarely need to change this
			value. If allocation reservations are turned off, this
			option will have no effect.
+4 −2
Original line number Diff line number Diff line
@@ -2977,6 +2977,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
	 * if we only get one now, that's enough to continue. The rest
	 * will be claimed after the conversion to extents.
	 */
	if (ocfs2_dir_resv_allowed(osb))
		data_ac->ac_resv = &oi->ip_la_data_resv;
	ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len);
	if (ret) {
@@ -3348,6 +3349,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
			goto bail;
		}

		if (ocfs2_dir_resv_allowed(osb))
			data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv;

		credits = ocfs2_calc_extend_credits(sb, el, 1);
+1 −0
Original line number Diff line number Diff line
@@ -356,6 +356,7 @@ struct ocfs2_super
	struct ocfs2_reservation_map	osb_la_resmap;

	unsigned int	osb_resv_level;
	unsigned int	osb_dir_resv_level;

	/* Next three fields are for local node slot recovery during
	 * mount. */
+6 −3
Original line number Diff line number Diff line
@@ -44,7 +44,11 @@ DEFINE_SPINLOCK(resv_lock);

#define	OCFS2_MIN_RESV_WINDOW_BITS	8
#define	OCFS2_MAX_RESV_WINDOW_BITS	1024
#define	OCFS2_RESV_DIR_WINDOW_BITS	OCFS2_MIN_RESV_WINDOW_BITS

int ocfs2_dir_resv_allowed(struct ocfs2_super *osb)
{
	return (osb->osb_resv_level && osb->osb_dir_resv_level);
}

static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,
					   struct ocfs2_alloc_reservation *resv)
@@ -56,8 +60,7 @@ static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,
		/* 8, 16, 32, 64, 128, 256, 512, 1024 */
		bits = 4 << osb->osb_resv_level;
	} else {
		/* For now, treat directories the same as files. */
		bits = 4 << osb->osb_resv_level;
		bits = 4 << osb->osb_dir_resv_level;
	}
	return bits;
}
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv);
void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv,
			 unsigned int flags);

int ocfs2_dir_resv_allowed(struct ocfs2_super *osb);

/**
 * ocfs2_resv_discard() - truncate a reservation
 * @resmap:
Loading