Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Use vmem_free() in dfl_free() and add dfl_alloc() #543

Closed
wants to merge 2 commits into from

Conversation

dweeezil
Copy link
Contributor

This change was lost, somehow, in e5f9a9a. Since the arrays can be
rather large, they need to be allocated with vmem_zalloc() and freed
with vmem_free().

@behlendorf
Copy link
Contributor

@dweeezil I must have accidentally applied a stale version e5f9a9a when this was merged. LGTM.

As for 9ac4097 see my question in openzfs/zfs#4529.

@@ -48,7 +48,7 @@ typedef struct dkioc_free_list_s {
} dkioc_free_list_t;

static inline void dfl_free(dkioc_free_list_t *dfl) {
kmem_free(dfl, DFL_SZ(dfl->dfl_num_exts));
vmem_free(dfl, DFL_SZ(dfl->dfl_num_exts));
Copy link
Contributor

@behlendorf behlendorf Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be a dfl_alloc() counterpart to prevent this kind of issue. I see it's directly calling vmem_alloc() in the trim code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make perfect sense. I think the only reason we don't have one is because illumos doesn't have one. I do like the idea of adding one. We've already got the kmem/vmem difference from the upstream and I suppose a dfl_alloc() would make the intention more obvious for future porting efforts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then let's add one. We're already forced to diverge slightly here, let's diverge in a way which can in theory be pushed back upstream.

This change was lost, somehow, in e5f9a9a.  Since the arrays can be
rather large, they need to be allocated with vmem_zalloc() via dfl_alloc()
and freed with vmem_free() via dfl_free().

The new dfl_alloc() function should be used to allocate object of type
dkioc_free_list_t in order that they're allocated from vmem.
The problem described in 2a5d574 also applies to XFS's file or inode
fallocate method.

When layered on XFS a warning will be emitted under CentOS7 when entering
either the file or inode fallocate method with PF_FSTRANS already set.
To avoid triggering this error PF_FSTRANS is cleared and then reset
in vn_space().
@dweeezil dweeezil changed the title Use vmem_free() in dfl_free() Use vmem_free() in dfl_free() and add dfl_alloc() Apr 26, 2016
@behlendorf
Copy link
Contributor

LGTM. My only concern would be if we need to leave PF_FSTRANS clear over truncate_range(). However, it looks like it's safe to leave it set.

@lorddoskias
Copy link

The "disable PF_FSTRANS" portions LGTM. However, I'd like to make it clear that the issue stems from the portion of XFS which is writing pages to disk, in my bug report it just so happened that page write code was invoked from fallocate. Having patched the fallocate callsite doesn't mean such warnings won't occur in the future. In any case, I'm happy with this version being merged.

@dweeezil
Copy link
Contributor Author

Regarding the truncate_range() callback, according to torvalds/linux@17cf28a, it was only ever supported by tmpfs. It didn't appear to me that tmpfs ever cared about the state of PF_FSTRANS.

As to the commit comment, I mainly cloned the one from 2a5d574. I suppose some different wording could be in order.

@behlendorf
Copy link
Contributor

OK, then I'll merge them both as is. I can add additional context to the commit message to make it clear under exactly what context this can occur and link back to the issue.

@behlendorf
Copy link
Contributor

Merged as:

ea2633a Clear PF_FSTRANS over spl_filp_fallocate()
3bf657b Use vmem_free() in dfl_free() and add dfl_alloc()

dweeezil added a commit to dweeezil/spl that referenced this pull request Sep 23, 2016
This change was lost, somehow, in e5f9a9a.  Since the arrays can be
rather large, they need to be allocated with vmem_zalloc() via dfl_alloc()
and freed with vmem_free() via dfl_free().

The new dfl_alloc() function should be used to allocate object of type
dkioc_free_list_t in order that they're allocated from vmem.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tim Chase <[email protected]>
Signed-off-by: Nikolay Borisov <[email protected]>
Closes openzfs#543
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants