[Ocfs2-devel] [PATCH 1/1] ocfs2: Add extended attribute support v3
Tiger Yang
tiger.yang at oracle.com
Tue Aug 5 19:34:53 PDT 2008
Mark Fasheh wrote:
> In order to protect against mmap changing the inline data state, you should
> hold a write lock on ip_alloc_sem across the call to ocfs2_xattr_ibody_find()
> and until the return from ocfs2_xattr_set_entry.
>
> So basically, ocfs2_xattr_set() should look like:
>
> ...
> down_write(&oi->ip_alloc_sem);
> ocfs2_ibody_find();
> ...
> ocfs2_xattr_set_entry();
> up_write(&oi->ip_alloc_sem);
> ...
>
> This way mmap can't change inline data state in between the calls to
> ibody_find and xattr_set_entry.
Thanks the guide. I think I have done what your said.
In ocfs2_ibody_find(), I checked the l_count/id_count with readable
semaphore. And in ocfs2_xattr_set_ibody, I checked it again and follow
by ocfs2_xattr_set_entry() with writable semaphore. If mmap change
l_count/id_count between those two function, I still have chance to know
it. And data in struct ocfs2_xattr_search which filled in
ocfs2_ibody_find() are not affected by mmap operations.
Best regards,
tiger
More information about the Ocfs2-devel
mailing list