- /* For append writes, we must take the range lock to protect size
- * and also move pos to current size before writing.
- */
- if (file->f_flags & O_APPEND) {
- struct lu_env *env;
- __u16 refcheck;
-
- append = true;
- range_lock_init(&range, 0, LUSTRE_EOF);
- result = range_lock(&lli->lli_write_tree, &range);
- if (result)
- RETURN(result);
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- GOTO(out, result = PTR_ERR(env));
- ll_merge_attr(env, inode);
- cl_env_put(env, &refcheck);
- iocb->ki_pos = i_size_read(inode);
- }
-
- /* Does this write touch multiple pages?
- *
- * This partly duplicates the PAGE_SIZE check above, but must come
- * after range locking for append writes because it depends on the
- * write position (ki_pos).
- */
- if ((iocb->ki_pos & (PAGE_SIZE-1)) + count > PAGE_SIZE)
- goto out;
-