summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/xattr-cache.h
blob: 3e12742a90fe05dcefc6611875a7f2bc1714ab03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
  Copyright (c) 2009 Z RESEARCH, Inc. <http://www.zresearch.com>
  This file is part of GlusterFS.

  GlusterFS is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 3 of the License,
  or (at your option) any later version.

  GlusterFS is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see
  <http://www.gnu.org/licenses/>.
*/

#ifndef __XATTR_CACHE_H__
#define __XATTR_CACHE_H__


#include "glusterfs.h"
#include "inode.h"

typedef struct __xattr_cache_handle {
	loc_t loc;
	fd_t  *fd;
} xattr_cache_handle_t;


typedef struct __xattr_cache_entry {
	char *key;               /* name of the xattr */
	int32_t *array;          /* value */
	size_t len;              /* length of array in bytes */
	inode_t *inode;          /* inode for which the entry is for */

	xattr_cache_handle_t *handle;
	unsigned char dirty;
	unsigned long nraccess;  /* number of times accessed */
} xattr_cache_entry_t;


typedef struct __xattr_cache {
	size_t size;
	pthread_mutex_t lock;
	xattr_cache_entry_t **entries;
} xattr_cache_t;


xattr_cache_t * posix_xattr_cache_init (size_t size);

int posix_xattr_cache_read (xlator_t *this, xattr_cache_handle_t *handle, 
			    char *key, int32_t *array, size_t len);

int posix_xattr_cache_write (xlator_t *this, xattr_cache_handle_t *handle,
			     char *key, int32_t *array, size_t len);

int posix_xattr_cache_flush (xlator_t *this, xattr_cache_handle_t *handle);

int posix_xattr_cache_flush_all (xlator_t *this);


#endif /* __XATTR_CACHE_H__ */