diff options
-rw-r--r-- | fs/gfs2/inode.c | 86 | ||||
-rw-r--r-- | fs/gfs2/inode.h | 4 | ||||
-rw-r--r-- | fs/gfs2/ops_address.c | 8 | ||||
-rw-r--r-- | fs/gfs2/ops_file.c | 2 |
4 files changed, 5 insertions, 95 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index ea9ca239c878..ce7f83306909 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -1234,92 +1234,6 @@ fail: | |||
1234 | return error; | 1234 | return error; |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | /** | ||
1238 | * glock_compare_atime - Compare two struct gfs2_glock structures for sort | ||
1239 | * @arg_a: the first structure | ||
1240 | * @arg_b: the second structure | ||
1241 | * | ||
1242 | * Returns: 1 if A > B | ||
1243 | * -1 if A < B | ||
1244 | * 0 if A == B | ||
1245 | */ | ||
1246 | |||
1247 | static int glock_compare_atime(const void *arg_a, const void *arg_b) | ||
1248 | { | ||
1249 | const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a; | ||
1250 | const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b; | ||
1251 | const struct lm_lockname *a = &gh_a->gh_gl->gl_name; | ||
1252 | const struct lm_lockname *b = &gh_b->gh_gl->gl_name; | ||
1253 | |||
1254 | if (a->ln_number > b->ln_number) | ||
1255 | return 1; | ||
1256 | if (a->ln_number < b->ln_number) | ||
1257 | return -1; | ||
1258 | if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE) | ||
1259 | return 1; | ||
1260 | if (gh_a->gh_state == LM_ST_SHARED && (gh_b->gh_flags & GL_ATIME)) | ||
1261 | return 1; | ||
1262 | |||
1263 | return 0; | ||
1264 | } | ||
1265 | |||
1266 | /** | ||
1267 | * gfs2_glock_nq_m_atime - acquire multiple glocks where one may need an | ||
1268 | * atime update | ||
1269 | * @num_gh: the number of structures | ||
1270 | * @ghs: an array of struct gfs2_holder structures | ||
1271 | * | ||
1272 | * Returns: 0 on success (all glocks acquired), | ||
1273 | * errno on failure (no glocks acquired) | ||
1274 | */ | ||
1275 | |||
1276 | int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs) | ||
1277 | { | ||
1278 | struct gfs2_holder **p; | ||
1279 | unsigned int x; | ||
1280 | int error = 0; | ||
1281 | |||
1282 | if (!num_gh) | ||
1283 | return 0; | ||
1284 | |||
1285 | if (num_gh == 1) { | ||
1286 | ghs->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC); | ||
1287 | if (ghs->gh_flags & GL_ATIME) | ||
1288 | error = gfs2_glock_nq_atime(ghs); | ||
1289 | else | ||
1290 | error = gfs2_glock_nq(ghs); | ||
1291 | return error; | ||
1292 | } | ||
1293 | |||
1294 | p = kcalloc(num_gh, sizeof(struct gfs2_holder *), GFP_KERNEL); | ||
1295 | if (!p) | ||
1296 | return -ENOMEM; | ||
1297 | |||
1298 | for (x = 0; x < num_gh; x++) | ||
1299 | p[x] = &ghs[x]; | ||
1300 | |||
1301 | sort(p, num_gh, sizeof(struct gfs2_holder *), glock_compare_atime,NULL); | ||
1302 | |||
1303 | for (x = 0; x < num_gh; x++) { | ||
1304 | p[x]->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC); | ||
1305 | |||
1306 | if (p[x]->gh_flags & GL_ATIME) | ||
1307 | error = gfs2_glock_nq_atime(p[x]); | ||
1308 | else | ||
1309 | error = gfs2_glock_nq(p[x]); | ||
1310 | |||
1311 | if (error) { | ||
1312 | while (x--) | ||
1313 | gfs2_glock_dq(p[x]); | ||
1314 | break; | ||
1315 | } | ||
1316 | } | ||
1317 | |||
1318 | kfree(p); | ||
1319 | return error; | ||
1320 | } | ||
1321 | |||
1322 | |||
1323 | static int | 1237 | static int |
1324 | __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) | 1238 | __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) |
1325 | { | 1239 | { |
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 46917edfdd6c..b57f448b15bc 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
@@ -50,12 +50,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, | |||
50 | struct gfs2_inode *ip); | 50 | struct gfs2_inode *ip); |
51 | int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to); | 51 | int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to); |
52 | int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); | 52 | int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); |
53 | |||
54 | int gfs2_glock_nq_atime(struct gfs2_holder *gh); | 53 | int gfs2_glock_nq_atime(struct gfs2_holder *gh); |
55 | int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs); | ||
56 | |||
57 | int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr); | 54 | int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr); |
58 | |||
59 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); | 55 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); |
60 | 56 | ||
61 | #endif /* __INODE_DOT_H__ */ | 57 | #endif /* __INODE_DOT_H__ */ |
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 2f7ef980d029..8676c39d0d73 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -217,7 +217,7 @@ static int gfs2_readpage(struct file *file, struct page *page) | |||
217 | } | 217 | } |
218 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh); | 218 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh); |
219 | do_unlock = 1; | 219 | do_unlock = 1; |
220 | error = gfs2_glock_nq_m_atime(1, &gh); | 220 | error = gfs2_glock_nq_atime(&gh); |
221 | if (unlikely(error)) | 221 | if (unlikely(error)) |
222 | goto out_unlock; | 222 | goto out_unlock; |
223 | } | 223 | } |
@@ -282,7 +282,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping, | |||
282 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, | 282 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, |
283 | LM_FLAG_TRY_1CB|GL_ATIME, &gh); | 283 | LM_FLAG_TRY_1CB|GL_ATIME, &gh); |
284 | do_unlock = 1; | 284 | do_unlock = 1; |
285 | ret = gfs2_glock_nq_m_atime(1, &gh); | 285 | ret = gfs2_glock_nq_atime(&gh); |
286 | if (ret == GLR_TRYFAILED) | 286 | if (ret == GLR_TRYFAILED) |
287 | goto out_noerror; | 287 | goto out_noerror; |
288 | if (unlikely(ret)) | 288 | if (unlikely(ret)) |
@@ -354,7 +354,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page, | |||
354 | 354 | ||
355 | 355 | ||
356 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|LM_FLAG_TRY_1CB, &ip->i_gh); | 356 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|LM_FLAG_TRY_1CB, &ip->i_gh); |
357 | error = gfs2_glock_nq_m_atime(1, &ip->i_gh); | 357 | error = gfs2_glock_nq_atime(&ip->i_gh); |
358 | if (unlikely(error)) { | 358 | if (unlikely(error)) { |
359 | if (error == GLR_TRYFAILED) | 359 | if (error == GLR_TRYFAILED) |
360 | error = AOP_TRUNCATED_PAGE; | 360 | error = AOP_TRUNCATED_PAGE; |
@@ -609,7 +609,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, | |||
609 | * on this path. All we need change is atime. | 609 | * on this path. All we need change is atime. |
610 | */ | 610 | */ |
611 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); | 611 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); |
612 | rv = gfs2_glock_nq_m_atime(1, &gh); | 612 | rv = gfs2_glock_nq_atime(&gh); |
613 | if (rv) | 613 | if (rv) |
614 | goto out; | 614 | goto out; |
615 | 615 | ||
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index eabf6c61a96a..c2be216eb928 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -253,7 +253,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) | |||
253 | u32 fsflags; | 253 | u32 fsflags; |
254 | 254 | ||
255 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); | 255 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); |
256 | error = gfs2_glock_nq_m_atime(1, &gh); | 256 | error = gfs2_glock_nq_atime(&gh); |
257 | if (error) | 257 | if (error) |
258 | return error; | 258 | return error; |
259 | 259 | ||