[Ocfs2-devel] + sysctl-use-rcu-protected-sysctl-for-ocfs-group-add-helper.patch added to -mm tree

Eric W. Biederman ebiederm at xmission.com
Fri Jan 8 16:55:07 PST 2010


Joel Becker <Joel.Becker at oracle.com> writes:

> On Fri, Jan 08, 2010 at 03:54:20PM -0800, akpm at linux-foundation.org wrote:
>> 
>> The patch titled
>>      sysctl: use RCU protected sysctl for ocfs group add helper
>> has been added to the -mm tree.  Its filename is
>>      sysctl-use-rcu-protected-sysctl-for-ocfs-group-add-helper.patch
>
> NAK until I can figure out how to make it always succeed.  We can't have
> umount "succeed" like this.
>
> Maybe the solution is GFP_ATOMIC.  Maybe the solution is to lock on the
> setting end.  But this isn't it.

My observation is that most of the issues rcu_string are memory allocation
issues.

Suppose we define rcu_string as:

struct rcu_string_head {
        char *str;
	size_t size;
        char data[];
}

#define DEFINE_RCU_STRING(NAME, SIZE, VAL)	\
struct {					\
	char *str;       			\
	size_t size;				\
        char data[SIZE + SIZE];		        \
} NAME = {					\
	.str = NAME.data,			\
        .size = SIZE,				\
        .data = VAL,				\
}

Accesses would be:
        char *str; 
	rcu_read_lock();
        str = rcu_deref(NAME.str);
        ....
	rcu_read_unlock();

Updates would be:
        char *next;
	mutex_lock(&rcu_string_mutex);
        next = rcu_string->data;
        if (next == rcu_string->str)
        	next = rcu_string->data + rcu_string->size;
        memcpy(next, somestring_from_somewhere, rcu_string->size);
        next[rcu_string->size - 1] = '\0';
        rcu_string->str = next;
        synchronize_rcu();
        mutex_unlock(&rcu_string_mutex);

Thoughts?

Eric



More information about the Ocfs2-devel mailing list