diff mbox series

[5.10,12/19] vboxsf: Make vboxsf_dir_create() return the handle for the created file

Message ID 20210813150523.032839314@linuxfoundation.org
State New
Headers show
Series None | expand

Commit Message

Greg KH Aug. 13, 2021, 3:07 p.m. UTC
From: Hans de Goede <hdegoede@redhat.com>

commit ab0c29687bc7a890d1a86ac376b0b0fd78b2d9b6 upstream

Make vboxsf_dir_create() optionally return the vboxsf-handle for
the created file. This is a preparation patch for adding atomic_open
support.

Fixes: 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/vboxsf/dir.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Greg KH Aug. 15, 2021, 11:43 a.m. UTC | #1
On Fri, Aug 13, 2021 at 09:31:58PM +0200, Pavel Machek wrote:
> Hi!

> 

> > commit ab0c29687bc7a890d1a86ac376b0b0fd78b2d9b6 upstream

> > 

> > Make vboxsf_dir_create() optionally return the vboxsf-handle for

> > the created file. This is a preparation patch for adding atomic_open

> > support.

> 

> Follow up commits using this functionality are in 5.13 but not in

> 5.10, so I believe we don't need this in 5.10, either?


It was asked to be backported, so I'll leave it in for now, thanks.

greg k-h
Hans de Goede Aug. 15, 2021, 1:57 p.m. UTC | #2
Hi,

On 8/13/21 9:31 PM, Pavel Machek wrote:
> Hi!

> 

>> commit ab0c29687bc7a890d1a86ac376b0b0fd78b2d9b6 upstream

>>

>> Make vboxsf_dir_create() optionally return the vboxsf-handle for

>> the created file. This is a preparation patch for adding atomic_open

>> support.

> 

> Follow up commits using this functionality are in 5.13 but not in

> 5.10, so I believe we don't need this in 5.10, either?

> 

> (Plus someone familiar with the code should check if we need "vboxsf:

> Honor excl flag to the dir-inode create op" in 5.10; it may have same

> problem).


Actually those follow up commits fix an actual bug, so I was expecting
the person who did the backport to also submit the rest of the set.

FWIW having these patches in but not the cannot hurt.

Hopefully the rest applies cleanly, I don't know.

To be clear I'm talking about also adding the following to patches
to 5.10.y:

02f840f90764 ("vboxsf: Add vboxsf_[create|release]_sf_handle() helpers")
52dfd86aa568 ("vboxsf: Add support for the atomic_open directory-inode op")

I have no idea of these will apply cleanly.

Regards,

Hans
Greg KH Aug. 16, 2021, 8:49 a.m. UTC | #3
On Sun, Aug 15, 2021 at 03:57:24PM +0200, Hans de Goede wrote:
> Hi,

> 

> On 8/13/21 9:31 PM, Pavel Machek wrote:

> > Hi!

> > 

> >> commit ab0c29687bc7a890d1a86ac376b0b0fd78b2d9b6 upstream

> >>

> >> Make vboxsf_dir_create() optionally return the vboxsf-handle for

> >> the created file. This is a preparation patch for adding atomic_open

> >> support.

> > 

> > Follow up commits using this functionality are in 5.13 but not in

> > 5.10, so I believe we don't need this in 5.10, either?

> > 

> > (Plus someone familiar with the code should check if we need "vboxsf:

> > Honor excl flag to the dir-inode create op" in 5.10; it may have same

> > problem).

> 

> Actually those follow up commits fix an actual bug, so I was expecting

> the person who did the backport to also submit the rest of the set.

> 

> FWIW having these patches in but not the cannot hurt.

> 

> Hopefully the rest applies cleanly, I don't know.

> 

> To be clear I'm talking about also adding the following to patches

> to 5.10.y:

> 

> 02f840f90764 ("vboxsf: Add vboxsf_[create|release]_sf_handle() helpers")

> 52dfd86aa568 ("vboxsf: Add support for the atomic_open directory-inode op")

> 

> I have no idea of these will apply cleanly.


They do, now queued up, thanks.

greg k-h
Sudip Mukherjee Aug. 17, 2021, 3:52 p.m. UTC | #4
On Sun, Aug 15, 2021 at 2:57 PM Hans de Goede <hdegoede@redhat.com> wrote:
>

> Hi,

>

> On 8/13/21 9:31 PM, Pavel Machek wrote:

> > Hi!

> >

> >> commit ab0c29687bc7a890d1a86ac376b0b0fd78b2d9b6 upstream

> >>

> >> Make vboxsf_dir_create() optionally return the vboxsf-handle for

> >> the created file. This is a preparation patch for adding atomic_open

> >> support.

> >

> > Follow up commits using this functionality are in 5.13 but not in

> > 5.10, so I believe we don't need this in 5.10, either?

> >

> > (Plus someone familiar with the code should check if we need "vboxsf:

> > Honor excl flag to the dir-inode create op" in 5.10; it may have same

> > problem).

>

> Actually those follow up commits fix an actual bug, so I was expecting

> the person who did the backport to also submit the rest of the set.


I only track Greg's failed messages when I find time for stable and
this one was one of those. So, no idea who has originally requested
this and why were the other two not requested.

-- 
Regards
Sudip
Hans de Goede Aug. 17, 2021, 6:21 p.m. UTC | #5
Hi,

On 8/17/21 5:52 PM, Sudip Mukherjee wrote:
> On Sun, Aug 15, 2021 at 2:57 PM Hans de Goede <hdegoede@redhat.com> wrote:

>>

>> Hi,

>>

>> On 8/13/21 9:31 PM, Pavel Machek wrote:

>>> Hi!

>>>

>>>> commit ab0c29687bc7a890d1a86ac376b0b0fd78b2d9b6 upstream

>>>>

>>>> Make vboxsf_dir_create() optionally return the vboxsf-handle for

>>>> the created file. This is a preparation patch for adding atomic_open

>>>> support.

>>>

>>> Follow up commits using this functionality are in 5.13 but not in

>>> 5.10, so I believe we don't need this in 5.10, either?

>>>

>>> (Plus someone familiar with the code should check if we need "vboxsf:

>>> Honor excl flag to the dir-inode create op" in 5.10; it may have same

>>> problem).

>>

>> Actually those follow up commits fix an actual bug, so I was expecting

>> the person who did the backport to also submit the rest of the set.

> 

> I only track Greg's failed messages when I find time for stable and

> this one was one of those. So, no idea who has originally requested

> this and why were the other two not requested.


I understand, thank you for backporting the 2 failing commits.

Regards,

Hans
diff mbox series

Patch

--- a/fs/vboxsf/dir.c
+++ b/fs/vboxsf/dir.c
@@ -253,7 +253,7 @@  static int vboxsf_dir_instantiate(struct
 }
 
 static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
-			     umode_t mode, bool is_dir, bool excl)
+			     umode_t mode, bool is_dir, bool excl, u64 *handle_ret)
 {
 	struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent);
 	struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb);
@@ -278,28 +278,32 @@  static int vboxsf_dir_create(struct inod
 	if (params.result != SHFL_FILE_CREATED)
 		return -EPERM;
 
-	vboxsf_close(sbi->root, params.handle);
-
 	err = vboxsf_dir_instantiate(parent, dentry, &params.info);
 	if (err)
-		return err;
+		goto out;
 
 	/* parent directory access/change time changed */
 	sf_parent_i->force_restat = 1;
 
-	return 0;
+out:
+	if (err == 0 && handle_ret)
+		*handle_ret = params.handle;
+	else
+		vboxsf_close(sbi->root, params.handle);
+
+	return err;
 }
 
 static int vboxsf_dir_mkfile(struct inode *parent, struct dentry *dentry,
 			     umode_t mode, bool excl)
 {
-	return vboxsf_dir_create(parent, dentry, mode, false, excl);
+	return vboxsf_dir_create(parent, dentry, mode, false, excl, NULL);
 }
 
 static int vboxsf_dir_mkdir(struct inode *parent, struct dentry *dentry,
 			    umode_t mode)
 {
-	return vboxsf_dir_create(parent, dentry, mode, true, true);
+	return vboxsf_dir_create(parent, dentry, mode, true, true, NULL);
 }
 
 static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry)