|
@@ -1234,92 +1234,6 @@ fail:
|
|
|
return error;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * glock_compare_atime - Compare two struct gfs2_glock structures for sort
|
|
|
- * @arg_a: the first structure
|
|
|
- * @arg_b: the second structure
|
|
|
- *
|
|
|
- * Returns: 1 if A > B
|
|
|
- * -1 if A < B
|
|
|
- * 0 if A == B
|
|
|
- */
|
|
|
-
|
|
|
-static int glock_compare_atime(const void *arg_a, const void *arg_b)
|
|
|
-{
|
|
|
- const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a;
|
|
|
- const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b;
|
|
|
- const struct lm_lockname *a = &gh_a->gh_gl->gl_name;
|
|
|
- const struct lm_lockname *b = &gh_b->gh_gl->gl_name;
|
|
|
-
|
|
|
- if (a->ln_number > b->ln_number)
|
|
|
- return 1;
|
|
|
- if (a->ln_number < b->ln_number)
|
|
|
- return -1;
|
|
|
- if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE)
|
|
|
- return 1;
|
|
|
- if (gh_a->gh_state == LM_ST_SHARED && (gh_b->gh_flags & GL_ATIME))
|
|
|
- return 1;
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * gfs2_glock_nq_m_atime - acquire multiple glocks where one may need an
|
|
|
- * atime update
|
|
|
- * @num_gh: the number of structures
|
|
|
- * @ghs: an array of struct gfs2_holder structures
|
|
|
- *
|
|
|
- * Returns: 0 on success (all glocks acquired),
|
|
|
- * errno on failure (no glocks acquired)
|
|
|
- */
|
|
|
-
|
|
|
-int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs)
|
|
|
-{
|
|
|
- struct gfs2_holder **p;
|
|
|
- unsigned int x;
|
|
|
- int error = 0;
|
|
|
-
|
|
|
- if (!num_gh)
|
|
|
- return 0;
|
|
|
-
|
|
|
- if (num_gh == 1) {
|
|
|
- ghs->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
|
|
|
- if (ghs->gh_flags & GL_ATIME)
|
|
|
- error = gfs2_glock_nq_atime(ghs);
|
|
|
- else
|
|
|
- error = gfs2_glock_nq(ghs);
|
|
|
- return error;
|
|
|
- }
|
|
|
-
|
|
|
- p = kcalloc(num_gh, sizeof(struct gfs2_holder *), GFP_KERNEL);
|
|
|
- if (!p)
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- for (x = 0; x < num_gh; x++)
|
|
|
- p[x] = &ghs[x];
|
|
|
-
|
|
|
- sort(p, num_gh, sizeof(struct gfs2_holder *), glock_compare_atime,NULL);
|
|
|
-
|
|
|
- for (x = 0; x < num_gh; x++) {
|
|
|
- p[x]->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
|
|
|
-
|
|
|
- if (p[x]->gh_flags & GL_ATIME)
|
|
|
- error = gfs2_glock_nq_atime(p[x]);
|
|
|
- else
|
|
|
- error = gfs2_glock_nq(p[x]);
|
|
|
-
|
|
|
- if (error) {
|
|
|
- while (x--)
|
|
|
- gfs2_glock_dq(p[x]);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- kfree(p);
|
|
|
- return error;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
static int
|
|
|
__gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
|
|
|
{
|