kmem.h \
list.h \
parent.h \
+ spinlock.h \
xfs_inode.h \
xfs_log_recover.h \
xfs_metadump.h \
#include "kmem.h"
#include "libfrog/radix-tree.h"
#include "atomic.h"
+#include "spinlock.h"
#include "xfs_types.h"
#include "xfs_fs.h"
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019-20 RedHat, Inc.
+ * All Rights Reserved.
+ */
+#ifndef __LIBXFS_SPINLOCK_H__
+#define __LIBXFS_SPINLOCK_H__
+
+/*
+ * This implements kernel compatible spinlock exclusion semantics. These,
+ * however, are not spinlocks, as spinlocks cannot be reliably implemented in
+ * userspace without using realtime scheduling task contexts. Hence this
+ * interface is implemented with pthread mutexes and so can block, but this is
+ * no different to the kernel RT build which replaces spinlocks with mutexes.
+ * Hence we know it works.
+ */
+
+typedef pthread_mutex_t spinlock_t;
+
+#define spin_lock_init(l) pthread_mutex_init(l, NULL)
+#define spin_lock(l) pthread_mutex_lock(l)
+#define spin_trylock(l) (pthread_mutex_trylock(l) != EBUSY)
+#define spin_unlock(l) pthread_mutex_unlock(l)
+
+#endif /* __LIBXFS_SPINLOCK_H__ */
struct timespec64 i_atime;
struct timespec64 i_mtime;
struct timespec64 i_ctime;
+ spinlock_t i_lock;
};
static inline uint32_t i_uid_read(struct inode *inode)
#define m_icount m_sb.sb_icount
#define m_ifree m_sb.sb_ifree
#define m_fdblocks m_sb.sb_fdblocks
+ spinlock_t m_sb_lock;
/*
* Bitsets of per-fs metadata that have been checked and/or are sick.
char *m_fsname; /* filesystem name */
int m_bsize; /* fs logical block size */
+ spinlock_t m_agirotor_lock;
xfs_agnumber_t m_agfrotor; /* last ag where space found */
xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
xfs_agnumber_t m_maxagi; /* highest inode alloc group */
unsigned int ili_last_fields; /* fields when flushed*/
unsigned int ili_fields; /* fields to be logged */
unsigned int ili_fsync_fields; /* ignored by userspace */
+ spinlock_t ili_lock;
};
typedef struct xfs_buf_log_item {
mp->m_flags = (LIBXFS_MOUNT_32BITINODES|LIBXFS_MOUNT_32BITINOOPT);
mp->m_sb = *sb;
INIT_RADIX_TREE(&mp->m_perag_tree, GFP_KERNEL);
- sbp = &(mp->m_sb);
+ sbp = &mp->m_sb;
+ spin_lock_init(&mp->m_sb_lock);
+ spin_lock_init(&mp->m_agirotor_lock);
xfs_sb_mount_common(mp, sb);
#include "kmem.h"
#include "libfrog/radix-tree.h"
#include "atomic.h"
+#include "spinlock.h"
#include "xfs_types.h"
#include "xfs_arch.h"
#endif
/* miscellaneous kernel routines not in user space */
-#define spin_lock_init(a) ((void) 0)
-#define spin_lock(a) ((void) 0)
-#define spin_unlock(a) ((void) 0)
#define likely(x) (x)
#define unlikely(x) (x)
ip->i_ino, iip);
#endif
- xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE);
+ spin_lock_init(&iip->ili_lock);
+
+ xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE);
iip->ili_inode = ip;
}
VFS_I(ip)->i_count = 1;
ip->i_ino = ino;
ip->i_mount = mp;
+ spin_lock_init(&VFS_I(ip)->i_lock);
+
error = xfs_imap(mp, tp, ip->i_ino, &ip->i_imap, 0);
if (error)
goto out_destroy;